jest-it-up
Advanced tools
Comparing version 2.0.2 to 2.2.0
@@ -11,3 +11,3 @@ const fs = require('fs') | ||
const reportPath = path.resolve( | ||
process.cwd(), | ||
path.dirname(configPath), | ||
coverageDirectory, | ||
@@ -14,0 +14,0 @@ 'coverage-summary.json', |
@@ -1,12 +0,14 @@ | ||
const getNewThresholds = (thresholds, coverages, margin) => | ||
const getNewThresholds = (thresholds, coverages, margin, tolerance) => | ||
Object.entries(thresholds).reduce((acc, [type, threshold]) => { | ||
const { pct: coverage } = coverages[type] | ||
const desiredCoverage = coverage - tolerance | ||
// Only update threshold if new coverage is higher than | ||
// current threshold + margin | ||
if (coverage >= threshold + margin) { | ||
if (desiredCoverage >= threshold + margin) { | ||
acc[type] = { | ||
prev: threshold, | ||
next: coverage, | ||
diff: +(coverage - threshold).toFixed(2), | ||
next: desiredCoverage, | ||
diff: +(desiredCoverage - threshold).toFixed(2), | ||
} | ||
@@ -13,0 +15,0 @@ } |
@@ -13,11 +13,18 @@ #!/usr/bin/env node | ||
module.exports = async ({ | ||
config = 'jest.config.js', | ||
dryRun = false, | ||
interactive = false, | ||
margin = 0, | ||
tolerance = 0, | ||
silent = false, | ||
} = {}) => { | ||
const configPath = path.resolve(process.cwd(), 'jest.config.js') | ||
const configPath = path.resolve(process.cwd(), config) | ||
const { thresholds, coverages } = await getData(configPath) | ||
const newThresholds = getNewThresholds(thresholds, coverages, margin) | ||
const newThresholds = getNewThresholds( | ||
thresholds, | ||
coverages, | ||
margin, | ||
tolerance, | ||
) | ||
const { changes, data } = getChanges(configPath, newThresholds) | ||
@@ -46,3 +53,3 @@ | ||
outputResult(dryRun) | ||
outputResult(configPath, dryRun) | ||
} |
const { yellow } = require('ansi-colors') | ||
const outputResult = dryRun => { | ||
const outputResult = (configPath, dryRun) => { | ||
console.log( | ||
dryRun | ||
? `No changes made to ${yellow('jest.config.js')}. (dry-run mode)` | ||
: `Done! Please record the changes to ${yellow('jest.config.js')}.`, | ||
? `No changes made to ${yellow(configPath)}. (dry-run mode)` | ||
: `Done! Please record the changes to ${yellow(configPath)}.`, | ||
) | ||
@@ -9,0 +9,0 @@ } |
{ | ||
"name": "jest-it-up", | ||
"version": "2.0.2", | ||
"version": "2.2.0", | ||
"description": "Automatically bump up global Jest thresholds whenever coverage goes above them", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -66,8 +66,10 @@ # jest-it-up | ||
Options: | ||
-m, --margin <margin> minimum threshold increase (default: 0) | ||
-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 | ||
-h, --help display help for command | ||
-c, --config <path> path to a Jest config file (default: 'jest.config.js') | ||
-m, --margin <margin> minimum threshold increase (default: 0) | ||
-t, --tolerance <tolerance> threshold difference from actual coverage | ||
-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 | ||
-h, --help display help for command | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9350
134
75