Code coverage reports
A good way to understand the amount and the trends of unit test coverage for your Angular project is through a code coverage report.
In order to generate the report for your app, execute the following command from your project
folder:
$ npx ng test --browsers ChromiumNoSandbox --watch=false --code-coverage
The resulting report will be created as an HTML file under a folder named coverage
; execute the following command to view it in your browser:
$ npx http-server -c-1 -o -p 9875 ./coverage
Install http-server
as a development dependency in your project.
Here's the folder-level sample coverage report generated by istanbul/nyc
for LemonMart:
Figure 9.20: Istanbul code coverage report for LemonMart
You can drill down on a particular folder, such as src/app/auth
, and get a file-level report, as shown here:
Figure 9.21: Istanbul code coverage report for src/app/auth
You can drill down further to...