Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: avoid reporting parents of failing tests in summary #47579

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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