October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Angular Code Coverage: Generate Reports and Set Thresholds

Generate an Angular coverage report with ng test --coverage, then configure report formats, file selection, thresholds, and CI behavior for the project’s Vitest or Karma runner.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run ng test --coverage in a current Angular CLI project to generate a code coverage report in coverage/; open coverage/index.html to browse it. New Angular CLI projects use Vitest by default, while Karma remains supported, so check the project’s test runner before copying runner-specific configuration.

Generate and open an Angular coverage report

  1. From the Angular workspace root, run ng test --coverage. For Vitest, install its coverage provider first if it is not already present: npm install -D @vitest/coverage-v8. Angular documents equivalent installation commands for Yarn, pnpm, and Bun in its code coverage guide.

    As an Amazon Associate I earn from qualifying purchases.

  2. When the test run completes, open coverage/index.html in a browser. The report’s HTML view lets you navigate from summary percentages into file-level coverage details.

    Free tools Windows power users keep installed

    One-click scans. No signup required.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For routine reporting, set coverage to true in the relevant test target in angular.json. Configuration names and supported options are documented in the ng test reference.

Check which test runner the project uses

Angular’s current testing documentation says new CLI projects use Vitest with jsdom by default; Karma remains supported. The Angular CLI testing overview and ng test reference describe the current setup and runner options. Do not assume a project created earlier has switched runners: its Angular CLI version and test target determine which settings apply.

Runner Coverage setup When it fits
Vitest Install @vitest/coverage-v8 as a development dependency for coverage; configure options through the Angular test target. Default for new Angular CLI projects; Node with jsdom is the standard environment.
Karma Use Karma’s coverage reporter configuration, including coverageReporter.check.global for minimum thresholds. Existing Karma projects or tests that rely on its browser-based workflow. Angular continues to support it.

Coverage does not require a real browser in every project. Angular’s default Vitest setup uses Node and jsdom; a browser run can be useful for browser-specific APIs or debugging, and Vitest browser mode requires installing a browser provider. For Karma’s documented headless Chrome CI example, see Testing with Karma and Jasmine.

Configure files, formats, and display bands

In angular.json, configure coverage options under the project’s test target. The current CLI option names are coverage, coverage-include, coverage-exclude, and coverage-reporters; Angular’s configuration guide presents the corresponding workspace settings in camel case, such as coverageInclude and coverageReporters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose formats based on who or what consumes the output, and keep the included-file policy stable if you want coverage comparisons to mean the same thing over time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set coverage thresholds that CI can enforce

Angular’s coverage configuration supports minimum percentages for statements, branches, functions, and lines. Its guide shows 80 for each dimension as an example configuration, not as a universal target or evidence-based quality benchmark. Choose values that match the team’s policy and codebase, then configure them in the test target. A run that falls below a configured threshold fails, allowing CI to block a change according to that policy.

Thresholds answer whether measured coverage clears a numeric floor; they do not show whether tests assert the right outcomes. A line can execute without its behavior being meaningfully checked, so read percentages alongside the tests and the file-level report rather than treating a high score as proof of test quality.

Run coverage in CI

Angular notes that CI environments commonly set CI=true, which enables a single non-interactive test run. If the environment does not set it, use ng test --no-watch --no-progress to avoid watch mode and progress output. Keep the command consistent with the project’s runner and its configured coverage provider.

For Karma, Angular documents this headless-browser example: ng test --no-watch --no-progress --browsers=ChromeHeadless. It is Karma-specific; do not add it to a Vitest workflow by assumption. See Angular’s Karma and Jasmine guide for its context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recognize legacy Karma instructions

Older Angular instructions, including the Angular v18 coverage guide, use ng test --no-watch --code-coverage and configure Karma’s check reporter in karma.conf.js. That syntax is useful when maintaining a matching legacy Karma setup, but it should not be pasted into a current Vitest project without checking the Angular CLI version and runner. For current CLI documentation, use ng test --coverage.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.