Inconsistent output with --coverage
See original GitHub issue🐛 Bug Report
When code-covered files exist in the root directory, the --coverage
output will include the name of the directory. This is not desirable in CI scenarios where the working directory will vary.
Actual
https://github.com/azz/jest-istanbul-issue/tree/master
When a file exists at root (above), the output is:
$ jest --coverage
PASS ./index.test.js
PASS src/file.test.js
-------------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-------------------------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
jest-istanbul-issue | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
jest-istanbul-issue/src | 100 | 100 | 100 | 100 | |
file.js | 100 | 100 | 100 | 100 | |
-------------------------|----------|----------|----------|----------|-------------------|
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 1.983s
Ran all test suites.
Done in 2.98s.
Note the jest-istanbul-issue
above.
Expected
https://github.com/azz/jest-istanbul-issue/tree/good-case
When it doesn’t:
$ jest --coverage
PASS src/file.test.js
√ it works (1ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
file.js | 100 | 100 | 100 | 100 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.708s
Ran all test suites.
Done in 2.76s.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Lcov inconsistent coverage - Stack Overflow
I started using lcov about a month back. The coverage count seems inconsistent. The first run reported about ...
Read more >Inconsistent coverage results using dotCover console runner ...
The coverage results are always 0% or change from run to run (even if there were no changes in the analyzed assemblies). Possible...
Read more >Dotnet Core code coverage inconsistent - Sonar Community
We're getting very inconsistent results with the code coverage and have linked it to the output names of the trx / coverage files....
Read more >Print Quality Defect: EP Process Results in Inconsistent ...
ssue description. Output characteristics: Toner coverage is blotchy and inconsistent. Toner starvation is seen on the printed page.
Read more >Inconsistent behaviour on `paths` when used with `expose_as ...
artifacts: + expose_as: tests when: always reports: junit: report.xml coverage_report: coverage_format: cobertura path: coverage.xml + paths: + - public ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
IMO the second case should include
/src
as well. So everything is always relative to the root of the projectrootDir
.Awesome! Yeah, or at least if passed some sort of
root
option. Would you mind filing an issue in the istanbul repo? Then whenever that’s fixed, we can use that option (or update the version if it’s made the default) and close this issue here 🙂