jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Coverage report doesn't include entirely uncovered files outside of project roots

Open benjaminjkraft opened this issue 2 years ago • 0 comments

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:
    • rootDir set to the repo root
    • collectCoverageFrom set to src
    • a project whose roots are just src/test
  • A test in src/test which covers src/impl/covered.js, but leaves src/impl/uncovered.js uncovered

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

benjaminjkraft avatar Jan 25 '23 21:01 benjaminjkraft