@vroskus/compare-coverage-thresholds
v1.0.6
Published
Tool for comparing code coverage thresholds values in package.json agaist the generated json coverage summary report.
Downloads
10
Readme
@vroskus/check-coverage-thresholds
Tool for comparing code coverage thresholds values in package.json agaist the generated json coverage summary report.
Installation
Call:
npm install -D @vroskus/check-coverage-thresholds
yarn add -D @vroskus/check-coverage-thresholds
Usage
- Make sure that your test framework uses
json-summary
reporter and has already produced acoverage/coverage-summary.json
. It is needed to get coverage results for analysis. - Ensure that you have some threshold values specified in package.json (you can start with
0
). Example:
// package.json
...
"jest": {
"coverageThreshold": {
"global": {
"lines": 0,
"statements": 0,
"branches": 0,
"functions": 0,
}
}
}
...
- Call
check-coverage-thresholds
after running tests, for example:
// package.json
...
"scripts": {
"test": "jest",
"posttest": "check-coverage-thresholds",
}
...
When the tool is called, it finds coverage information, compares results with stored threshold values, and exits with exit code 0 if threshold values are equal or higher, otherwise script exits with exit code 1 printing out not met values.