Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test_runner: make logic more straightforward
1. formatTestReport: inline the `const error`
2. move the check for `data.details?.error` out of formatError
   to its sole caller, formatTestReport, which makes more sense.
3. collapse the nested ternary expressions in formatTestReport to one.
  • Loading branch information
vassudanagunta committed Sep 1, 2025
commit adada91bfcc8ca09e4a39d6d622aa7c37674078e
4 changes: 1 addition & 3 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 @@ -81,8 +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;
const err = showErrorDetails && data.details?.error && !hasChildren ? formatError(data.details.error, indent) : '';

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