-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Closed
Copy link
Labels
Description
Version
27.5.1
Steps to reproduce
- Clone my repro repo: https://github.com/j3tan/jest-coverage-path-issue
npm install
npm test
- Observe failure
Expected behavior
I expect to see src/Foo/
to pass with 100% coverage when using this configuration:
coverageThreshold: {
'src/Foo/': {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
}
}
The ending /
in the path group should be respected
Actual behavior
I see src/Foo/
failed with 50% coverage because src/Foobar/
is also aggregated.
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 50 | 100 | 50 | 50 |
Foo | 100 | 100 | 100 | 100 |
add.js | 100 | 100 | 100 | 100 |
Foobar | 0 | 100 | 0 | 0 |
subtract.js | 0 | 100 | 0 | 0 | 2
--------------|---------|----------|---------|---------|-------------------
Jest: "src/Foo/" coverage threshold for statements (100%) not met: 50%
Jest: "src/Foo/" coverage threshold for lines (100%) not met: 50%
Jest: "src/Foo/" coverage threshold for functions (100%) not met: 50%
Additional context
The ending /
is ignored due to these lines:
The path.resolve
removes the ending slash.
Using glob
matcher is not an option here since that checks per-file coverage thresholds instead of the aggregate path style.
Environment
System:
OS: macOS 12.3.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
npmPackages:
jest: ^27.5.1 => 27.5.1