Skip to content

Commit 8720ac6

Browse files
committed
test_runner: print failed coverage reports with dot runner
Fixes: #60884 Refs: #52655 When running tests with both the dot reporter and coverage reports, if a coverage report fails (e.g., line coverage threshold not met), there was no visible output indicating the failure. The process would exit with a failure code, but only dots would be printed with no explanation. This commit adds collection and display of coverage threshold failure diagnostics in the dot reporter. When coverage threshold checks fail, error diagnostic messages are now displayed at the end of the test output, similar to how failed tests are displayed. The coverage error messages are collected from test:diagnostic events with level='error' that are emitted by the test runner when coverage thresholds are not met.
1 parent 66a687f commit 8720ac6

File tree

1 file changed

+11
-0
lines changed
  • lib/internal/test_runner/reporter

1 file changed

+11
-0
lines changed

lib/internal/test_runner/reporter/dot.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = async function* dot(source) {
1010
let count = 0;
1111
let columns = getLineLength();
1212
const failedTests = [];
13+
const coverageErrors = [];
1314
for await (const { type, data } of source) {
1415
if (type === 'test:pass') {
1516
yield `${colors.green}.${colors.reset}`;
@@ -18,6 +19,10 @@ module.exports = async function* dot(source) {
1819
yield `${colors.red}X${colors.reset}`;
1920
ArrayPrototypePush(failedTests, data);
2021
}
22+
if (type === 'test:diagnostic' && data.level === 'error') {
23+
// Collect coverage errors (coverage threshold failures)
24+
ArrayPrototypePush(coverageErrors, data.message);
25+
}
2126
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
2227
yield '\n';
2328

@@ -33,6 +38,12 @@ module.exports = async function* dot(source) {
3338
yield formatTestReport('test:fail', test);
3439
}
3540
}
41+
if (coverageErrors.length > 0) {
42+
yield `\n${colors.red}Coverage errors:${colors.white}\n\n`;
43+
for (const error of coverageErrors) {
44+
yield `${colors.red}${error}${colors.white}\n`;
45+
}
46+
}
3647
};
3748

3849
function getLineLength() {

0 commit comments

Comments
 (0)