Skip to content

Commit

Permalink
test_runner: output errors of suites
Browse files Browse the repository at this point in the history
PR-URL: #50361
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
MoLow authored and targos committed Nov 11, 2023
1 parent e20b272 commit 913e4b9
Show file tree
Hide file tree
Showing 4 changed files with 584 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ class SpecReporter extends Transform {
} else if (todo !== undefined) {
title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`;
}
const error = this.#formatError(data.details?.error, indent);
if (hasChildren) {
// If this test has had children - it was already reported, so slightly modify the output
return `${prefix}${indent}${color}${symbols['arrow:right']}${white}${title}\n`;
const err = data.details?.error?.failureType === 'subtestsFailed' ? '' : error;
return `${prefix}${indent}${color}${symbols['arrow:right']}${white}${title}\n${err}`;
}
const error = this.#formatError(data.details?.error, indent);
if (skip !== undefined) {
color = gray;
symbol = symbols['hyphen:minus'];
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/test-runner/output/hooks_spec_reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';
require('../../../common');
const fixtures = require('../../../common/fixtures');
const spawn = require('node:child_process').spawn;

const child = spawn(process.execPath,
['--no-warnings', '--test-reporter', 'spec', fixtures.path('test-runner/output/hooks.js')],
{ stdio: 'pipe' });
// eslint-disable-next-line no-control-regex
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
child.stderr.pipe(process.stderr);
Loading

0 comments on commit 913e4b9

Please sign in to comment.