From d71eee3ac8fe108c1badf53ea7454ee762de6bd3 Mon Sep 17 00:00:00 2001 From: AZ & QZ Date: Mon, 2 Mar 2026 13:07:00 -0700 Subject: [PATCH] test_runner: print failed coverage reports with dot runner When running tests with both the dot reporter and coverage reports, if the coverage report fails there was no output (other than the dots) but the program exits with a failure status code. This change adds coverage failure output to the dot reporter, similar to how the spec reporter handles coverage events. Now users can see why the command failed without needing to check F12 console. Fixes #60884 Signed-off-by: AZ & QZ --- lib/internal/test_runner/reporter/dot.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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() {