When I run the Jest coverage report, it prints out each type of coverage and the percentage by file. The last column that shows the uncovered lines gets truncated when there are more than ~4-5 lines. Is there a way to print all of the uncovered lines?
-------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-------------------------------|----------|----------|----------|----------|----------------|
All files | 75.57 | 69.18 | 74.21 | 75.83 | |
js/components/catalyst | 80.74 | 72.97 | 80.16 | 81.85 | |
JobGroup.jsx | 57.14 | 50 | 44.44 | 60 |... 33,34,38,73 |
...etc
This shows me that JobGroup.jsx has lines 33,34,38, and 73, but there are more, and I'd like to see them all at once.
Testing uncovered linesThey are marked red, because they are completely untouched by any test. These lines are within an if-statement that is only entered when the passed two values together will be greater than 100.
On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.
Code coverage results are displayed in the Coverage tool window, in the Project tool window, and in the editor after you run at least one configuration with coverage. Results of the code coverage analysis are saved to the coverage folder in the IDE system directory.
Uncover is a simple and easy to use command-line tool for measuring code coverage of applications. Code coverage is an important part of software testing. It gives you information on which areas of your code are exercised in testing and which are not, enabling you to improve your test suites to test more of your code.
Is there a way to print all of the uncovered lines?
I'm using React + TypeScript + Jest. In my project, I run npm test -- --coverage
, and the file with the remaining uncovered lines is under the coverage
directory:
<project name>\<directory>\<directory>\coverage\lcov-report\index.html
(Your file path may have a variation on the coverage
part. :-))
Then I navigate to the file of interest:
All lines highlighted in pink are uncovered:
This is an alternative solution that some may find helpful.
Personally, I use VSCode, and there is a plugin available called "Code Coverage", it does something similar to the other answer here, by Super Jade, except it will highlight the code after you run a coverage test, like so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With