Checking the coverage of changed and added files
- Separate
coverage threshold
settings for new and changed files - Ability to specify
target
branch relative to whichdiff
will be calculated
- Install:
npm i jest-coverage-gate -D
- Add
jest-coverage-gate
to thecoverageReporters
list of your Jest configuration:
{
coverageReporters: [
"clover", "json", "lcov", "text", // default
[
'jest-coverage-gate',
{
since: 'develop', // origin/develop, OR origin/develop...HEAD, OR commitHash...commitHash
modified: {
branches: 50,
functions: 50,
lines: 50,
statements: 50,
},
added: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
],
],
}
- Run Jest:
jest --coverage