Skip to content

Commit

Permalink
test: enhance dot reporter to display failed test names
Browse files Browse the repository at this point in the history
Add failed test names and execution times to dot reporter output, improving issue identification without verbose reporting.

Fixes: nodejs#51769
  • Loading branch information
mihir254 committed Apr 23, 2024
1 parent 3115041 commit 8e939e7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/internal/test_runner/reporter/dot.js
@@ -1,18 +1,24 @@
'use strict';

const colors = require('internal/util/colors');
const {
MathMax,
} = primordials;

const failedTestSymbol = '\u2716 ';

module.exports = async function* dot(source) {
let count = 0;
let columns = getLineLength();
for await (const { type } of source) {
let failedTests = [];

for await (const { type, data } of source) {
if (type === 'test:pass') {
yield '.';
}
if (type === 'test:fail') {
yield 'X';
failedTests.push(data);
}
if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
yield '\n';
Expand All @@ -23,6 +29,14 @@ module.exports = async function* dot(source) {
}
}
yield '\n';

if (failedTests.length > 0) {
yield `${colors.red}${failedTestSymbol} failing tests:${colors.white}\n`;
for (const test of failedTests) {
const message = `${colors.red}${failedTestSymbol} ${test.name} ${colors.gray}(${test.details.duration_ms}ms)\n`;
yield message;
}
}
};

function getLineLength() {
Expand Down

0 comments on commit 8e939e7

Please sign in to comment.