Automatically bump up global Jest thresholds whenever coverage goes above them
npm install jest-it-up



Ensure incremental coverage gains are not lost, and positively reinforce good testing habits. Automatically bump up global Jest thresholds whenever coverage goes above them.
!Demo
- Node.js 20+
- Conventional jest.config.js (package.json config unsupported)
- json-summary coverage report (see usage)
``console`
npm install --save-dev jest-it-up
jest-it-up exposes a standalone CLI tool (see options), but you most likely want to use it in a post-test script.
Within package.json:
`jscollectCoverage
{
"scripts": {
"test": "jest --coverage", // or set to true in Jest configjest.config.js
"posttest": "jest-it-up" // must run from the same directory as `
}
}
within jest.config.js:
`js`
module.exports = {
coverageReporters: [
'json-summary', // plus any other reporters, e.g. "lcov", "text", "text-summary"
],
coverageThreshold: {
global: {
branches: 0, // or your current numbers
functions: 0,
lines: 0,
statements: 0,
},
},
}
Once tests finish running, jest-it-up will update configured thresholds to match higher coverage numbers, if any.
`console
$ jest-it-up --help
Usage: jest-it-up [options]
Options:
-c, --config
-m, --margin
-t, --tolerance
-i, --interactive ask for confirmation before applying changes
-s, --silent do not output messages
-d, --dry-run process but do not change files
-v, --version output the version number
-p, --precision number of threshold decimal places to persist
-h, --help display help for command
``