Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
For most current Angular CLI projects, run ng test --coverage to generate a code coverage report. Open coverage/index.html for the navigable HTML report. New Angular CLI projects use Vitest by default, while Karma remains supported, so check which runner your project uses before copying runner-specific configuration.
Generate an Angular coverage report
- Run
ng test --coveragefrom the Angular project directory. Current Angular CLI documentation uses this command to generate coverage output. See Angular’s code coverage guide. - Open
coverage/index.htmlin a browser to browse the HTML report. Other report formats can be configured if your team or CI system needs them.
For Vitest coverage, install its coverage provider as a development dependency: @vitest/coverage-v8. Angular’s testing guide includes install commands for npm, Yarn, pnpm, and Bun. Follow the package-manager command that matches your project; the provider is required for Vitest coverage reporting. See Angular’s testing overview.
Check whether the project uses Vitest or Karma
Angular’s current CLI documentation says new projects use Vitest by default, and lists both vitest and karma as supported test runners. The choice matters because coverage setup differs between them. Check the project’s Angular CLI configuration and existing test setup rather than assuming that a command or configuration copied from an older tutorial applies. See the ng test reference.
- Vitest: Angular describes Node with jsdom as the default unit-test environment for new projects. Use the Vitest coverage provider and the Angular CLI coverage options. A browser run may be useful for browser-specific APIs or debugging; Vitest browser mode requires a browser provider.
- Karma: Karma remains supported and has its own coverage reporter configuration. Angular’s Karma guide shows how to set minimum coverage levels under
coverageReporter.check.globaland includes a Chrome Headless CI command.
Configure coverage in angular.json
To generate coverage as part of routine test runs, set coverage to true in the project’s test target in angular.json. The current Angular CLI option names include coverage, coverage-include, coverage-exclude, and coverage-reporters; in the JSON configuration, the corresponding options use camel-case names such as coverageInclude and coverageReporters. Consult the coverage guide and CLI reference when editing the options for your project.
#1 Best Overall
Choose the files in the report
Use coverageInclude and coverageExclude to control which files appear in the report. Make the inclusion and exclusion rules explicit and keep them consistent across local runs and CI: excluding files changes the set of code being measured, so percentages from reports with different file sets are not directly comparable.
Select report formats
Set coverageReporters to the formats your workflow needs. Angular’s current CLI reference lists HTML, LCOV, LCOV-only, text, text-summary, Cobertura, JSON, and JSON summary variants. The HTML report is useful for navigating coverage by file; choose machine-readable output when another tool in your workflow consumes the results.
Rank #2
Set thresholds separately from display watermarks
Angular documents coverage thresholds for statements, branches, functions, and lines. Its example uses 80% for each dimension to illustrate configuration; it is not a universal target or a documented recommendation. Choose thresholds that fit your codebase and team policy. When a configured threshold is not met, the test command fails.
coverageWatermarks sets low and high bands used for color-coding in the HTML report. Watermarks affect how the report looks; they do not enforce minimum coverage. Use thresholds for enforcement and watermarks for visual interpretation.
Rank #3
Run coverage reliably in CI
Angular says CI environments commonly set CI=true, which the CLI detects to run tests once without interactive watch behavior. If your CI environment does not set it, use ng test --no-watch --no-progress to request a single non-interactive run. Keep the command consistent with the runner configured for the project.
For Karma specifically, Angular documents this headless Chrome example: ng test --no-watch --no-progress --browsers=ChromeHeadless. Do not assume that Karma’s browser flags or reporter configuration apply to a Vitest project. See Angular’s Karma and Jasmine guide.
Rank #4
Interpret coverage as a signal, not a quality score
A coverage percentage estimates how much code was exercised according to the report’s categories: statements, branches, functions, or lines. It can help identify code paths that tests may not reach, but it does not show whether assertions check the right outcomes. A high percentage alone cannot establish that a test suite validates behavior or is high quality.
Free tools Windows power users keep installed
One-click scans. No signup required.
Keep the runner, measured file set, report format, and threshold policy in view when comparing results. Angular’s current guidance is at Code coverage, with runner options in the ng test reference and setup details in the testing overview.
Older Angular projects: check the version before using legacy syntax
Angular v18 documentation shows the older Karma-oriented command ng test --no-watch --code-coverage and configures a check reporter in karma.conf.js. That syntax and setup should not be pasted into a current Vitest project without first confirming the Angular CLI version and test runner. See the Angular v18 code coverage guide.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

