-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Version
30.2.0
Steps to reproduce
- Check example repository
- Check https://github.com/darekkay/jest-coverage/blob/master/README.md for instruction
Expected behavior
I'll describe my use case. A global threshold is configured as following:
coverageThreshold: {
global: {
statements: 85,
branches: 80,
functions: 85,
lines: 85
}
}
This makes it possible to commit completely untested files as long as the overall coverage is fulfilled. To solve this issue I would like to enforce every file being tested for at least 50%:
coverageThreshold: {
global: {
statements: 85,
branches: 80,
functions: 85,
lines: 85
},
"app/**/*.js": {
statements: 50,
branches: 50,
functions: 50,
lines: 50
}
}
However, this won't work as expected:
- First, running this config will fail if app/ and global point to the same files (which is expected as "If the file specified by path is not found, error is returned.").
- Second, now the global threshold is overruled by the "local" threshold.
It would be great to have an option to use a global threshold which always applies to all files in addition to glob/path thresholds for single file thresholds, similar to how Vitest does in NOTE section
Vitest counts all files, including those covered by glob-patterns, into the global coverage thresholds. This is different from Jest behavior.
{
coverage: {
thresholds: {
// Thresholds for all files
functions: 95,
branches: 70,
// Thresholds for matching glob pattern
'src/utils/**.ts': {
statements: 95,
functions: 90,
branches: 85,
lines: 80,
},
// Files matching this pattern will only have lines thresholds set.
// Global thresholds are not inherited.
'**/math.ts': {
lines: 100,
}
}
}
}
it should work for cross OS
Actual behavior
Currently, when using both global and path/glob thresholds, the global config combines the coverage for remaining files only (as documented).
Additional context
No response
Environment
Windows 7
jest v22.1.4
node v8.9.1
npm v5.6.0