Skip to content

Commit 313a274

Browse files
committed
test_runner: print coverage and diagnostic info with dot reporter
When using the dot reporter with coverage enabled, coverage threshold failures and coverage reports were not printed, only an exit code was returned. This made it impossible to know why the test run failed. This change adds handling for test:diagnostic and test:coverage events to the dot reporter, matching the behavior of the spec reporter. Fixes: #60884
1 parent 9bcfbeb commit 313a274

File tree

1 file changed

+24
-1
lines changed
  • lib/internal/test_runner/reporter

1 file changed

+24
-1
lines changed

lib/internal/test_runner/reporter/dot.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ const {
44
MathMax,
55
} = primordials;
66
const colors = require('internal/util/colors');
7-
const { formatTestReport } = require('internal/test_runner/reporter/utils');
7+
const { getCoverageReport } = require('internal/test_runner/utils');
8+
const {
9+
formatTestReport,
10+
reporterColorMap,
11+
reporterUnicodeSymbolMap,
12+
} = require('internal/test_runner/reporter/utils');
813

914
module.exports = async function* dot(source) {
1015
let count = 0;
1116
let columns = getLineLength();
1217
const failedTests = [];
18+
const diagnostics = [];
19+
let coverage;
1320
for await (const { type, data } of source) {
1421
if (type === 'test:pass') {
1522
yield `${colors.green}.${colors.reset}`;
@@ -25,8 +32,24 @@ module.exports = async function* dot(source) {
2532
columns = getLineLength();
2633
count = 0;
2734
}
35+
if (type === 'test:diagnostic' && data.level === 'error') {
36+
ArrayPrototypePush(diagnostics, data);
37+
}
38+
if (type === 'test:coverage') {
39+
coverage = data;
40+
}
2841
}
2942
yield '\n';
43+
if (diagnostics.length > 0) {
44+
for (const diagnostic of diagnostics) {
45+
const color = reporterColorMap[diagnostic.level] || reporterColorMap['test:diagnostic'];
46+
yield `${color}${reporterUnicodeSymbolMap['test:diagnostic']}${diagnostic.message}${colors.white}\n`;
47+
}
48+
if (coverage) {
49+
yield getCoverageReport('', coverage.summary,
50+
reporterUnicodeSymbolMap['test:coverage'], colors.blue, true);
51+
}
52+
}
3053
if (failedTests.length > 0) {
3154
yield `\n${colors.red}Failed tests:${colors.white}\n\n`;
3255
for (const test of failedTests) {

0 commit comments

Comments
 (0)