Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5a4c3e

Browse filesBrowse files
vassudanaguntaaduh95
authored andcommitted
test_runner: nix dead reporter code
reporter/utils.js formatTestReport: 1. hasChildren and showErrorDetails are never both true in existing calls. 2. Thus if hasChildren is true, showErrorDetails is false. 3. So `|| data.details?.error?.failureType === 'subtestsFailed'` is irrelevant. 4. And `\n${error}` never occurs. Even though all tests pass after this commit, what if future reporter code might make calls where both hasChildren and showErrorDetails are true? I will address this in the last commit of this PR. Trust me for now. PR-URL: #59700 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent 4f30c21 commit a5a4c3e
Copy full SHA for a5a4c3e

2 files changed

+4-13Lines changed: 4 additions & 13 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/reporter/spec.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/reporter/spec.js
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SpecReporter extends Transform {
5353
}
5454

5555
this.#failedTests = []; // Clean up the failed tests
56-
return ArrayPrototypeJoin(results, '\n'); ;
56+
return ArrayPrototypeJoin(results, '\n');
5757
}
5858
#handleTestReportEvent(type, data) {
5959
const subtest = ArrayPrototypeShift(this.#stack); // This is the matching `test:start` event
@@ -71,13 +71,8 @@ class SpecReporter extends Transform {
7171
ArrayPrototypeUnshift(this.#reported, msg);
7272
prefix += `${indent(msg.nesting)}${reporterUnicodeSymbolMap['arrow:right']}${msg.name}\n`;
7373
}
74-
let hasChildren = false;
75-
if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) {
76-
ArrayPrototypeShift(this.#reported);
77-
hasChildren = true;
78-
}
7974
const indentation = indent(data.nesting);
80-
return `${formatTestReport(type, data, prefix, indentation, hasChildren, false)}\n`;
75+
return `${formatTestReport(type, data, false, prefix, indentation)}\n`;
8176
}
8277
#handleEvent({ type, data }) {
8378
switch (type) {
Collapse file

‎lib/internal/test_runner/reporter/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/reporter/utils.js
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ function indent(nesting) {
5858
}
5959

6060
function formatError(error, indent) {
61-
if (!error) return '';
6261
const err = error.code === 'ERR_TEST_FAILURE' ? error.cause : error;
6362
const message = ArrayPrototypeJoin(
6463
RegExpPrototypeSymbolSplit(
@@ -68,7 +67,7 @@ function formatError(error, indent) {
6867
return `\n${indent} ${message}\n`;
6968
}
7069

71-
function formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, showErrorDetails = true) {
70+
function formatTestReport(type, data, showErrorDetails = true, prefix = '', indent = '') {
7271
let color = reporterColorMap[type] ?? colors.white;
7372
let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
7473
const { skip, todo, expectFailure } = data;
@@ -83,10 +82,7 @@ function formatTestReport(type, data, prefix = '', indent = '', hasChildren = fa
8382
title += ` # EXPECTED FAILURE`;
8483
}
8584

86-
const error = showErrorDetails ? formatError(data.details?.error, indent) : '';
87-
const err = hasChildren ?
88-
(!error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`) :
89-
error;
85+
const err = showErrorDetails && data.details?.error ? formatError(data.details.error, indent) : '';
9086

9187
if (skip !== undefined) {
9288
color = colors.gray;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.