Skip to content

Commit

Permalink
test: print test errors only when finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Llorx committed Dec 24, 2024
1 parent be9dc2d commit ce5c8c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SpecReporter extends Transform {
hasChildren = true;
}
const indentation = indent(data.nesting);
return `${formatTestReport(type, data, prefix, indentation, hasChildren)}\n`;
return `${formatTestReport(type, data, prefix, indentation, hasChildren, true)}\n`;
}
#handleEvent({ type, data }) {
switch (type) {
Expand Down
13 changes: 8 additions & 5 deletions lib/internal/test_runner/reporter/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function formatError(error, indent) {
return `\n${indent} ${message}\n`;
}

function formatTestReport(type, data, prefix = '', indent = '', hasChildren = false) {
function formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, avoidError = false) {
let color = reporterColorMap[type] ?? colors.white;
let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
const { skip, todo } = data;
Expand All @@ -71,10 +71,13 @@ function formatTestReport(type, data, prefix = '', indent = '', hasChildren = fa
} else if (todo !== undefined) {
title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`;
}
const error = formatError(data.details?.error, indent);
const err = hasChildren ?
(!error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`) :
error;
let err = "";
if (!avoidError) {
const error = formatError(data.details?.error, indent);
err = hasChildren ?
(!error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`) :
error;
}
if (skip !== undefined) {
color = colors.gray;
symbol = reporterUnicodeSymbolMap['hyphen:minus'];
Expand Down

0 comments on commit ce5c8c0

Please sign in to comment.