Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SpecReporter extends Transform {
}

this.#failedTests = []; // Clean up the failed tests
return ArrayPrototypeJoin(results, '\n'); ;
return ArrayPrototypeJoin(results, '\n');
}
#handleTestReportEvent(type, data) {
const subtest = ArrayPrototypeShift(this.#stack); // This is the matching `test:start` event
Expand All @@ -71,13 +71,8 @@ class SpecReporter extends Transform {
ArrayPrototypeUnshift(this.#reported, msg);
prefix += `${indent(msg.nesting)}${reporterUnicodeSymbolMap['arrow:right']}${msg.name}\n`;
}
let hasChildren = false;
if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) {
ArrayPrototypeShift(this.#reported);
hasChildren = true;
}
const indentation = indent(data.nesting);
return `${formatTestReport(type, data, prefix, indentation, hasChildren, false)}\n`;
return `${formatTestReport(type, data, false, prefix, indentation)}\n`;
}
#handleEvent({ type, data }) {
switch (type) {
Expand Down
8 changes: 2 additions & 6 deletions lib/internal/test_runner/reporter/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function indent(nesting) {
}

function formatError(error, indent) {
if (!error) return '';
const err = error.code === 'ERR_TEST_FAILURE' ? error.cause : error;
const message = ArrayPrototypeJoin(
RegExpPrototypeSymbolSplit(
Expand All @@ -68,7 +67,7 @@ function formatError(error, indent) {
return `\n${indent} ${message}\n`;
}

function formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, showErrorDetails = true) {
function formatTestReport(type, data, showErrorDetails = true, prefix = '', indent = '') {
let color = reporterColorMap[type] ?? colors.white;
let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
const { skip, todo } = data;
Expand All @@ -81,10 +80,7 @@ function formatTestReport(type, data, prefix = '', indent = '', hasChildren = fa
title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`;
}

const error = showErrorDetails ? formatError(data.details?.error, indent) : '';
const err = hasChildren ?
(!error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`) :
error;
const err = showErrorDetails && data.details?.error ? formatError(data.details.error, indent) : '';

if (skip !== undefined) {
color = colors.gray;
Expand Down
Loading