question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Oct 16, 2018

IMO the second case should include /src as well. So everything is always relative to the root of the project rootDir.

1reaction
SimenBcommented, Apr 30, 2022

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 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found