Skip to content

Commit ec24aba

Browse files
MoLowtargos
authored andcommitted
test_runner: avoid reporting parents of failing tests in summary
PR-URL: #47579 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 12f0fa3 commit ec24aba

File tree

4 files changed

+4
-25
lines changed

4 files changed

+4
-25
lines changed

lib/internal/test_runner/reporter/spec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const assert = require('assert');
1515
const Transform = require('internal/streams/transform');
1616
const { inspectWithNoCustomRetry } = require('internal/errors');
1717
const { green, blue, red, white, gray, hasColors } = require('internal/util/colors');
18+
const { kSubtestsFailed } = require('internal/test_runner/test');
1819
const { getCoverageReport } = require('internal/test_runner/utils');
1920

2021
const inspectOptions = { __proto__: null, colors: hasColors, breakLength: Infinity };
@@ -107,7 +108,9 @@ class SpecReporter extends Transform {
107108
#handleEvent({ type, data }) {
108109
switch (type) {
109110
case 'test:fail':
110-
ArrayPrototypePush(this.#failedTests, data);
111+
if (data.details?.error?.failureType !== kSubtestsFailed) {
112+
ArrayPrototypePush(this.#failedTests, data);
113+
}
111114
return this.#handleTestReportEvent(type, data);
112115
case 'test:pass':
113116
return this.#handleTestReportEvent(type, data);

test/fixtures/test-runner/output/spec_reporter.snapshot

-9
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,12 @@
399399
*
400400
*
401401

402-
subtest sync throw fail (*ms)
403-
'1 subtest failed'
404-
405402
sync throw non-error fail (*ms)
406403
Symbol(thrown symbol from sync throw non-error fail)
407404

408405
+long running (*ms)
409406
'test did not finish before its parent and was cancelled'
410407

411-
top level (*ms)
412-
'1 subtest failed'
413-
414408
sync skip option is false fail (*ms)
415409
Error: this should be executed
416410
*
@@ -487,9 +481,6 @@
487481
*
488482
*
489483

490-
subtest sync throw fails (*ms)
491-
'2 subtests failed'
492-
493484
timed out async test (*ms)
494485
'test timed out after *ms'
495486

test/fixtures/test-runner/output/spec_reporter_cli.snapshot

-12
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@
408408
*
409409
*
410410

411-
subtest sync throw fail (*ms)
412-
[Error: 1 subtest failed
413-
]
414-
415411
sync throw non-error fail (*ms)
416412
[Error: Symbol(thrown symbol from sync throw non-error fail)
417413
]
@@ -420,10 +416,6 @@
420416
[Error: test did not finish before its parent and was cancelled
421417
]
422418

423-
top level (*ms)
424-
[Error: 1 subtest failed
425-
]
426-
427419
sync skip option is false fail (*ms)
428420
Error: this should be executed
429421
*
@@ -504,10 +496,6 @@
504496
*
505497
*
506498

507-
subtest sync throw fails (*ms)
508-
[Error: 2 subtests failed
509-
]
510-
511499
timed out async test (*ms)
512500
[Error: test timed out after *ms
513501
]

test/pseudo-tty/test_runner_default_reporter.out

-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,3 @@
5555

5656
[31m* should pass but parent fail [90m(*ms)[39m[39m
5757
[32m'test did not finish before its parent and was cancelled'[39m
58-
59-
[31m* parent [90m(*ms)[39m[39m
60-
[32m'2 subtests failed'[39m

0 commit comments

Comments
 (0)