From ec24abaa03706884d06a28b6678f513031b6b1ed Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 18 Apr 2023 10:36:56 +0300 Subject: [PATCH] test_runner: avoid reporting parents of failing tests in summary PR-URL: https://github.com/nodejs/node/pull/47579 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell --- lib/internal/test_runner/reporter/spec.js | 5 ++++- .../test-runner/output/spec_reporter.snapshot | 9 --------- .../test-runner/output/spec_reporter_cli.snapshot | 12 ------------ test/pseudo-tty/test_runner_default_reporter.out | 3 --- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/internal/test_runner/reporter/spec.js b/lib/internal/test_runner/reporter/spec.js index ecc20bb866a784..848b5cfa245d1e 100644 --- a/lib/internal/test_runner/reporter/spec.js +++ b/lib/internal/test_runner/reporter/spec.js @@ -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 }; @@ -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); diff --git a/test/fixtures/test-runner/output/spec_reporter.snapshot b/test/fixtures/test-runner/output/spec_reporter.snapshot index ad0c88c26fd97f..768204177014af 100644 --- a/test/fixtures/test-runner/output/spec_reporter.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter.snapshot @@ -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 * @@ -487,9 +481,6 @@ * * - subtest sync throw fails (*ms) - '2 subtests failed' - timed out async test (*ms) 'test timed out after *ms' diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot index 8f5cf3131b7759..ffbf636b748d81 100644 --- a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot @@ -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) ] @@ -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 * @@ -504,10 +496,6 @@ * * - subtest sync throw fails (*ms) - [Error: 2 subtests failed - ] - timed out async test (*ms) [Error: test timed out after *ms ] diff --git a/test/pseudo-tty/test_runner_default_reporter.out b/test/pseudo-tty/test_runner_default_reporter.out index f032cf0a291562..6787ceb6af708e 100644 --- a/test/pseudo-tty/test_runner_default_reporter.out +++ b/test/pseudo-tty/test_runner_default_reporter.out @@ -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