Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to show where missed coverage is on karma coverage

I have an Angular app and I'm giving testing a go but it's a nightmare to find where the coverage is needed.

the output shows the following:

=============================== Coverage summary ===============================      
Statements   : 91.67% ( 22/24 )
Branches     : 75% ( 3/4 )
Functions    : 75% ( 3/4 )
Lines        : 90.48% ( 19/21 )
================================================================================ 

Is there a way to see where these statements, branches, functions and lines are that are not covered?

e.g. some output that says

Statements:
1. file: some/file/name.js line:03
2. file: some/file/name.js line:06

Is that possible?

Thanks

like image 266
Liam Clarke Avatar asked Jan 25 '20 01:01

Liam Clarke


People also ask

How do I check my karma coverage report?

Open the index. html file inside the /coverage folder to see a report with your source code and code coverage values.

How do I find my coverage report?

If you want to reopen the Coverage tool window, select Run | Show Code Coverage Data from the main menu, or press Ctrl+Alt+F6 . The report shows the percentage of the code that has been executed or covered by tests. You can see the coverage result for classes, methods, and lines.

Is Karma coverage Istanbul reporter deprecated?

If you upgraded to Angular 11 recently, you might have noticed that karma-coverage-istanbul-reporter has been deprecated. It can simply be replaced with karma-coverage and by changing some things in karma. conf. js .

How coverage is calculated?

How is it measured? To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.


1 Answers

Angular CLI creates code coverage reports when using the following command (see Enable code coverage reports).

ng test --code-coverage

When the tests are complete, the command creates a new /coverage folder in the project or it overwrites its content if it existed before. Open the index.html file inside the /coverage folder to see a report with your source code and code coverage values.

like image 83
uminder Avatar answered Sep 22 '22 20:09

uminder