diff --git a/lib/internal/test_runner/reporter/spec.js b/lib/internal/test_runner/reporter/spec.js index 2092d22e3fe77f..c8cf61e5922083 100644 --- a/lib/internal/test_runner/reporter/spec.js +++ b/lib/internal/test_runner/reporter/spec.js @@ -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) { diff --git a/lib/internal/test_runner/reporter/utils.js b/lib/internal/test_runner/reporter/utils.js index 9b6cc96a185a9a..5cce2b91f76d10 100644 --- a/lib/internal/test_runner/reporter/utils.js +++ b/lib/internal/test_runner/reporter/utils.js @@ -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; @@ -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'];