diff --git a/lib/internal/test_runner/reporter/dot.js b/lib/internal/test_runner/reporter/dot.js index 45ff047bc4e5a0..4473c8511c6216 100644 --- a/lib/internal/test_runner/reporter/dot.js +++ b/lib/internal/test_runner/reporter/dot.js @@ -4,12 +4,13 @@ const { MathMax, } = primordials; const colors = require('internal/util/colors'); -const { formatTestReport } = require('internal/test_runner/reporter/utils'); +const { formatTestReport, getCoverageReport } = require('internal/test_runner/reporter/utils'); module.exports = async function* dot(source) { let count = 0; let columns = getLineLength(); const failedTests = []; + const coverageFailures = []; for await (const { type, data } of source) { if (type === 'test:pass') { yield `${colors.green}.${colors.reset}`; @@ -18,6 +19,16 @@ module.exports = async function* dot(source) { yield `${colors.red}X${colors.reset}`; ArrayPrototypePush(failedTests, data); } + if (type === 'test:coverage') { + // Check if coverage failed (threshold not met) + if (data.summary && ( + (data.summary.lines && data.summary.lines.pct < 100) || + (data.summary.functions && data.summary.functions.pct < 100) || + (data.summary.branches && data.summary.branches.pct < 100) + )) { + ArrayPrototypePush(coverageFailures, data); + } + } if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) { yield '\n'; @@ -33,6 +44,12 @@ module.exports = async function* dot(source) { yield formatTestReport('test:fail', test); } } + if (coverageFailures.length > 0) { + yield `\n${colors.red}Coverage report failed:${colors.white}\n\n`; + for (const coverage of coverageFailures) { + yield getCoverageReport('', coverage.summary, 'ℹ ', colors.blue, true); + } + } }; function getLineLength() {