UNPKG

@jobber/jest-a-coverage-slip-detector

Version:

Ensures that new files have jest coverage and that legacy files only increase

49 lines (42 loc) 1.23 kB
const { fromCoverageFiles, perFileCoverageReport, logViolations, } = require("./coverageUtilities"); const { mergeCoverageAndGenerateReports } = require("./mergeCoverage"); const { loadConfig } = require("./config"); exports.runPerFileCoverageTest = function runPerFileCoverageTest( mergePerformed = false, ) { const config = loadConfig(); if (config.input.alwaysMerge && !mergePerformed) { mergeCoverageAndGenerateReports(); } const { coverageSummary, coverageExceptions, coverageIgnore } = fromCoverageFiles(); const { filesBelowCoverageThreshold, exceptionsBelowCoverageThreshold, exceptionsAboveCoverageThreshold, coverageError, coverageWarn, } = perFileCoverageReport( coverageSummary, coverageIgnore, coverageExceptions, ); logViolations( filesBelowCoverageThreshold.concat(exceptionsBelowCoverageThreshold), config.messages.belowThreshold, exceptionsBelowCoverageThreshold.length > 0 ? config.messages.belowLegacyThreshold : undefined, ); logViolations( exceptionsAboveCoverageThreshold, config.messages.aboveThreshold, config.messages.regeneratePrompt, true, ); return coverageError || coverageWarn; };