Skip to content

Commit

Permalink
test_runner: avoid reporting parents of failing tests in summary
Browse files Browse the repository at this point in the history
PR-URL: #47579
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
MoLow authored Apr 18, 2023
1 parent 682256c commit d3b0a2a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
5 changes: 4 additions & 1 deletion lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const assert = require('assert');
const Transform = require('internal/streams/transform');
const { inspectWithNoCustomRetry } = require('internal/errors');
const { green, blue, red, white, gray, hasColors } = require('internal/util/colors');
const { kSubtestsFailed } = require('internal/test_runner/test');
const { getCoverageReport } = require('internal/test_runner/utils');

const inspectOptions = { __proto__: null, colors: hasColors, breakLength: Infinity };
Expand Down Expand Up @@ -107,7 +108,9 @@ class SpecReporter extends Transform {
#handleEvent({ type, data }) {
switch (type) {
case 'test:fail':
ArrayPrototypePush(this.#failedTests, data);
if (data.details?.error?.failureType !== kSubtestsFailed) {
ArrayPrototypePush(this.#failedTests, data);
}
return this.#handleTestReportEvent(type, data);
case 'test:pass':
return this.#handleTestReportEvent(type, data);
Expand Down
9 changes: 0 additions & 9 deletions test/fixtures/test-runner/output/spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,12 @@
*
*

subtest sync throw fail (*ms)
'1 subtest failed'

sync throw non-error fail (*ms)
Symbol(thrown symbol from sync throw non-error fail)

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

top level (*ms)
'1 subtest failed'

sync skip option is false fail (*ms)
Error: this should be executed
*
Expand Down Expand Up @@ -487,9 +481,6 @@
*
*

subtest sync throw fails (*ms)
'2 subtests failed'

timed out async test (*ms)
'test timed out after *ms'

Expand Down
12 changes: 0 additions & 12 deletions test/fixtures/test-runner/output/spec_reporter_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,6 @@
*
*

subtest sync throw fail (*ms)
[Error: 1 subtest failed
]

sync throw non-error fail (*ms)
[Error: Symbol(thrown symbol from sync throw non-error fail)
]
Expand All @@ -420,10 +416,6 @@
[Error: test did not finish before its parent and was cancelled
]

top level (*ms)
[Error: 1 subtest failed
]

sync skip option is false fail (*ms)
Error: this should be executed
*
Expand Down Expand Up @@ -504,10 +496,6 @@
*
*

subtest sync throw fails (*ms)
[Error: 2 subtests failed
]

timed out async test (*ms)
[Error: test timed out after *ms
]
Expand Down
3 changes: 0 additions & 3 deletions test/pseudo-tty/test_runner_default_reporter.out
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,3 @@

[31m* should pass but parent fail [90m(*ms)[39m[39m
[32m'test did not finish before its parent and was cancelled'[39m

[31m* parent [90m(*ms)[39m[39m
[32m'2 subtests failed'[39m

0 comments on commit d3b0a2a

Please sign in to comment.