jest-it-up
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -1,2 +0,8 @@ | ||
const getNewThresholds = (thresholds, coverages, margin, tolerance) => | ||
const getNewThresholds = ( | ||
thresholds, | ||
coverages, | ||
margin, | ||
tolerance, | ||
precision, | ||
) => | ||
Object.entries(thresholds).reduce((acc, [type, threshold]) => { | ||
@@ -6,10 +12,12 @@ const { pct: coverage } = coverages[type] | ||
const desiredCoverage = coverage - tolerance | ||
const factor = Math.pow(10, precision) | ||
const nextCoverage = Math.trunc(desiredCoverage * factor) / factor | ||
// Only update threshold if new coverage is higher than | ||
// current threshold + margin | ||
if (desiredCoverage >= threshold + margin) { | ||
if (nextCoverage > threshold + margin) { | ||
acc[type] = { | ||
prev: threshold, | ||
next: desiredCoverage, | ||
diff: +(desiredCoverage - threshold).toFixed(2), | ||
next: nextCoverage, | ||
diff: +(nextCoverage - threshold).toFixed(2), | ||
} | ||
@@ -16,0 +24,0 @@ } |
@@ -19,2 +19,3 @@ #!/usr/bin/env node | ||
silent = false, | ||
precision = 2, | ||
} = {}) => { | ||
@@ -29,2 +30,3 @@ const configPath = path.resolve(process.cwd(), config) | ||
tolerance, | ||
precision, | ||
) | ||
@@ -31,0 +33,0 @@ const { changes, data } = getChanges(configPath, newThresholds) |
{ | ||
"name": "jest-it-up", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Automatically bump up global Jest thresholds whenever coverage goes above them", | ||
@@ -41,9 +41,9 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "8.45.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"eslint": "8.56.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-prettier": "5.1.2", | ||
"husky": "8.0.3", | ||
"jest": "29.6.1", | ||
"lint-staged": "13.2.3", | ||
"prettier": "3.0.0" | ||
"jest": "29.7.0", | ||
"lint-staged": "15.2.0", | ||
"prettier": "3.1.1" | ||
}, | ||
@@ -50,0 +50,0 @@ "engines": { |
@@ -26,3 +26,3 @@ # jest-it-up | ||
jest-it-up exposes a standalone CLI tool (see [options](#options)), but you most likelly want to use it in a post-test script. | ||
jest-it-up exposes a standalone CLI tool (see [options](#options)), but you most likely want to use it in a post-test script. | ||
@@ -74,3 +74,4 @@ Within `package.json`: | ||
-v, --version output the version number | ||
-p, --precision number of threshold decimal places to persist | ||
-h, --help display help for command | ||
``` |
Sorry, the diff of this file is not supported yet
9707
144
76