jest
jest copied to clipboard
[Bug]: Coverage report doesn't include entirely uncovered files outside of project roots
Version
29.4.0
Steps to reproduce
Run npx jest --coverage in https://github.com/benjaminjkraft/jest-coverage-roots-issue.
Specifically, this project has:
- A Jest config with:
rootDirset to the repo rootcollectCoverageFromset tosrc- a project whose roots are just
src/test
- A test in
src/testwhich coverssrc/impl/covered.js, but leavessrc/impl/uncovered.jsuncovered
Expected behavior
Since collectCoverageFrom asks for coverage in all of src, and indeed reports coverage for src/covered.js, src/uncovered.js should be reported as uncovered.
Actual behavior
Coverage is only reported for src/covered.js:
$ npx jest --coverage
PASS tests src/test/test.test.js
f
✓ should return 1 (1 ms)
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
covered.js | 100 | 100 | 100 | 100 |
------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.531 s, estimated 1 s
Ran all test suites.
Additional context
No response
Environment
System:
OS: macOS 13.1
CPU: (10) x64 Apple M1 Max
Binaries:
Node: 16.17.1 - /nix/store/fyaisfdhkviz6sb628qxlmy5wcasqfhq-nodejs-16.17.1/bin/node
npm: 8.12.1 - ~/.local/bin/npm
npmPackages:
jest: ^29.4.0 => 29.4.0