Tool for Jest testing library that automatically bumps up code coverage thresholds as real code coverage improves.
npm install jest-coverage-thresholds-bumperjest.config.json, jest.config.js, and jest.config.ts configuration files, as well as jest section in package.json.
jest-coverage-thresholds-bumper helps to regularly update configured thresholds, so if your real coverage drops then Jest will report it immediately.
npm install -D jest-coverage-thresholds-bumper
json-summary reporter. It is needed to produce coverage results for analysis.
0). jest-coverage-thresholds-bumper only updates existing values. Example:
JavaScript
// jest.config.js
...
coverageThreshold: {
global: {
lines: 80,
statements: 80,
branches: 80,
functions: 80,
}
}
...
`
3. Call jest-coverage-thresholds-bumper after running tests, for example:
`json
// package.json
...
"scripts": {
"test": "jest",
"posttest": "jest-coverage-thresholds-bumper",
}
...
`
When the tool is called, it finds coverage information, compares results with stored threshold values, and bumps up threshold values if results are higher. Note that only defined thresholds are bumped up - i.e. if no thresholds exist, nothing will be bumped.
Options
`text
Usage: jest-coverage-thresholds-bumper [options]
Options:
--coverage-summary-path Path to Jest coverage results [string] [default: ./coverage/coverage-summary.json]
--config-path Path to Jest config file [string] [default: Search for jest.config.* files or "jest" section in package.json]
--margin Minimal threshold increase in per cent [number] [default: 0]
--dry-run Do analysis, but don't change any thresholds [boolean] [default: false]
--silent No console output unless something goes wrong [boolean] [default: false]
--help Show help [boolean]
--version Show version number [boolean]
`
FAQ
Q: How margin parameter works? What is it for?
A: Imagine that both real and expected coverage are at 90 percent and the margin is 1 percent. If you add a tiny test that increases real coverage by only 0.5 percent then this tool won't bump up the expected coverage. If you add more tests and real coverage improves to 91 or mor percent then your threshold will increase. Some people may use margin` parameter to ignore little fluctuations in code coverage during active development phase, which could fail builds.