If you want to see overall test coverage statistics than of course in Angular CLI you can just type, and see the bottom of your command prompt window

ng test --code-coverage

result:

if you want to see component's individual coverage of tests follow these steps.

  1. npm install --save-dev karma-teamcity-reporter

  2. Add require('karma-teamcity-reporter') to list of plugins in karma.conf.js

  3. ng test --code-coverage --reporters=teamcity,coverage-istanbul

note that list of reporters is comma-separated, as we have added a new reporter, teamcity.

after running this command you can see the folder coverage in your dir and open index.html for a graphical view of test coverage.

You can also set the coverage threshold that you want to achieve, in karma.conf.js, like this.

coverageIstanbulReporter: {
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true,
      thresholds: {
        statements: 90,
        lines: 90,
        branches: 90,
        functions: 90
      }
    },
Answer from ahmadalibaloch on Stack Overflow
🌐
Angular
angular.dev › guide › testing › code-coverage
Code coverage • Angular
If your team decides on a minimum amount to be unit tested, you can enforce this minimum in your configuration. For example, suppose you want the code base to have a minimum of 80% code coverage. To enable this, add the coverageThresholds option to your angular.json file:
🌐
Testing-angular
testing-angular.com › measuring-code-coverage
Measuring code coverage – Testing Angular
February 17, 2021 - ... Writing new code and changing existing code should not lower the coverage score, but gradually increase it. This means if your existing tests cover 75% lines of code, new code needs to be at least 75% covered.
Discussions

Feature request: Unit test coverage for .html files
I want to downvote this one as it comes from not understanding how the Angular framework works. Basically, ngIf is a directive. If you write your own directive you can then unit test that just fine. I would assume Angular is already unit testing their ngIf directive code that is in @angular/core so what would be the point of you checking it? Additionally, HTML is not a programming language. What you may be looking for is E2E testing which you can use cypress for. More on reddit.com
🌐 r/angular
9
0
July 28, 2023
ng test --code-coverage do not generate coverage dicretory
my question is where can i get the Coverage report and the url can i see the Coverage report in chrome ; eg Versions. Windows (7), ng version: 1.2.6 angular: 4.0.0 karma.conf.js module.exports = fu... More on github.com
🌐 github.com
9
August 7, 2017
Code Coverage For Angular Templates?
It's not usually done. It might be possible to do something with the ivy codegen (I don't think anyone has yet), but I'm not sure about that, and I don't think it would be that useful even if it did work. As much as possible try to leave logic out of your template. Yes you need *ngIf, *ngFor, etc, but as much as possible try to have them work on plain booleans, simple equality checks, arrays, etc with all the real logic in your component code or pipes were they can be tested. More on reddit.com
🌐 r/angular
16
10
May 18, 2020
Playwright code coverage
Hello, I had the same question and did some digging but I hit a wall. Playwright needs to update Component Testing to include Angular. Now is in experimental mode and it's supporting React. However for unit tests you can have code coverage. Hope this helps. Happy Easter! More on reddit.com
🌐 r/angular
9
1
April 18, 2025
🌐
TutorialsPoint
tutorialspoint.com › angular_cli › angular_cli_code_coverage.htm
Angular CLI - Code Coverage
In Angular development, the CLI ... you run the unit test. It is used to measure how many parts (or percentage) of your Angular codebase are executed by running the unit or integration test....
🌐
Angular
v17.angular.io › guide › testing-code-coverage
Code coverage
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
Angular Minds
angularminds.com › blog › methods-to-increase-code-coverage-in-angular
Methods to Increase Code Coverage in Angular
October 3, 2024 - Libraries like jest or Angular’s HttpClientTestingModule can help you create mock services and APIs, ensuring that tests focus solely on the component’s logic. ... Include edge cases in your tests to ensure that your application handles unexpected or extreme conditions gracefully. ... Ensure that all branches of conditional statements (e.g., if, switch) are executed. Write tests that cover each possible path. ... Leverage code coverage tools like Istanbul (via nyc) or coverage with Karma to identify untested branches.
🌐
Angular
angular.dev › cli › test
ng test • Angular
The builder uses the named configurations to run the given target. For more information, see https://angular.dev/reference/configs/workspace-config#alternate-build-configurations. ... Enables coverage reporting for tests. If not specified, the coverage configuration from a runner configuration file will be used if present.
Find elsewhere
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › products › azure › azure infrastructure blog
Enforcing Angular Unit Test Coverage in Azure DevOps Pipelines: A Step-by-Step Guide | Microsoft Community Hub
August 21, 2025 - - script: | angular_coverage=$(grep -oP 'line-rate="(\d+\.\d+)"' $(System.DefaultWorkingDirectory)/unittestintegration/src/ui/coverage/code-coverage.xml | head -1 | grep -oP '\d+\.\d+') angular_coverage=$(echo "$angular_coverage * 100" | bc) if (( $(echo "$angular_coverage < 70" | bc -l) )); then echo "Angular test coverage is below 70%: $angular_coverage%" exit 1 fi echo "Angular test coverage is above 70%: $angular_coverage%" displayName: Verify Angular test coverage-remote
🌐
Daniel Kreider
danielk.tech › home › angular-code-coverage
Angular Code Coverage (How to measure and use) | Daniel Kreider
December 9, 2024 - First of all, code coverage is a percentage of the code that gets tested when we run our suite of Angular tests.
🌐
Angular
v18.angular.dev › guide › testing › code-coverage
Code coverage • Angular
The code coverage percentages let you estimate how much of your code is tested. If your team decides on a set minimum amount to be unit tested, enforce this minimum with the Angular CLI.
🌐
Better Programming
betterprogramming.pub › how-to-reach-100-test-coverage-without-testing-anything-64d07d226bff
How to Write Useful Tests for Angular Components | by Michael Seemann | Better Programming
April 1, 2022 - Great! We have 100% code coverage. On every line, on every branch on every function. How could this be reached so easy? First of all you may noticed that the Component Class Testing approach is used.
🌐
Andrewhalil
andrewhalil.com › 2021 › 11 › 02 › test-code-coverage-within-angular-applications
Test Code Coverage in an Angular Application – andrewhalil.com
November 2, 2021 - Near the end of this post, I will explain how code coverage can be improved by you not just in your Angular applications, but with applications written with other development tools including .NET Core. Test coverage is a quantitative measurement of the level of testing that your application has.
🌐
Medium
medium.com › ngconf › angular-unit-testing-code-coverage-lies-603c6c85f801
Angular Unit Testing Code-Coverage Lies | by Jared Youtsey | ngconf | Medium
September 15, 2021 - The report only shows us what lines were executed, not what lines were tested. In Angular, when you compile a component in a unit test ngOnInit and everything it calls will get “covered” immediately.
🌐
Angular-book
angular-book.dev › ch04-06-coverage.html
Code Coverage - Angular Book
You can generate a coverage report for your unit tests by adding --code-coverage switch to the test command:
🌐
Medium
manivelarjunan.medium.com › angular-7-unit-testing-code-coverage-5c7a238315b6
Angular 7 + unit testing + code coverage | by Manivel Arjunan | Medium
December 29, 2018 - Angular 7 + unit testing + code coverage What is unit testing? Why unit testing is important? Angular 7 application configuration for unit testing, debug and code coverage. Basic Component unit …
🌐
Marmicode
marmicode.io › blog › angular-template-code-coverage-and-future-proof-testing
The Missing Ingredient for Angular Template Code Coverage and Future-Proof Testing | Marmicode
This article presents how turning on Ahead-Of-Time (AOT) compilation for your Angular tests enables accurate template code coverage, faster test execution, production-symmetry, and future-proof tests.
🌐
Angular
v17.angular.io › cli › test
Angular
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
GitHub
github.com › angular › angular-cli › issues › 7291
ng test --code-coverage do not generate coverage dicretory · Issue #7291 · angular/angular-cli
August 7, 2017 - module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular/cli'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular/cli/plugins/karma') ], client:{ clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { reports: [ 'html', 'lcovonly' ], fixWebpackSourcePaths: true }, angularCli: { environment: 'dev' }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun: false }); };
Author   hucheng91
🌐
Medium
diegoperezsalas.medium.com › how-to-write-a-jest-test-with-100-coverage-in-angular-27cfbda9a445
How to Achieve 100% Code Coverage with Jest Tests in Angular | by Diego Perez Salas | Medium
March 26, 2024 - In conclusion, achieving 100% code coverage with unit tests in Angular using Jest requires a thorough and comprehensive testing strategy. Unit tests should focus on testing the behavior and functionality of individual components, services, and ...