From 34a631de9de6d3c3f51c734cd5b4197803e3cc5d Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Sun, 2 Apr 2023 10:05:53 +0300 Subject: [PATCH] test_runner: hide failing tests title when all tests pass PR-URL: https://github.com/nodejs/node/pull/47370 Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- lib/internal/test_runner/reporter/spec.js | 4 ++++ test/message/test_runner_spec_reporter_successful.js | 6 ++++++ test/message/test_runner_spec_reporter_successful.out | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/message/test_runner_spec_reporter_successful.js create mode 100644 test/message/test_runner_spec_reporter_successful.out diff --git a/lib/internal/test_runner/reporter/spec.js b/lib/internal/test_runner/reporter/spec.js index d991f563a315c8..69681610e2c46a 100644 --- a/lib/internal/test_runner/reporter/spec.js +++ b/lib/internal/test_runner/reporter/spec.js @@ -124,6 +124,10 @@ class SpecReporter extends Transform { callback(null, this.#handleEvent({ type, data })); } _flush(callback) { + if (this.#failedTests.length === 0) { + callback(null, ''); + return; + } const results = [`\n${colors['test:fail']}${symbols['test:fail']}failing tests:${white}\n`]; for (let i = 0; i < this.#failedTests.length; i++) { ArrayPrototypePush(results, this.#formatTestReport( diff --git a/test/message/test_runner_spec_reporter_successful.js b/test/message/test_runner_spec_reporter_successful.js new file mode 100644 index 00000000000000..e5e21e29e15e3e --- /dev/null +++ b/test/message/test_runner_spec_reporter_successful.js @@ -0,0 +1,6 @@ +// Flags: --no-warnings --test-reporter=spec +'use strict'; +require('../common'); +const { it } = require('node:test'); + +it('should pass', () => {}); diff --git a/test/message/test_runner_spec_reporter_successful.out b/test/message/test_runner_spec_reporter_successful.out new file mode 100644 index 00000000000000..e1576063021fc5 --- /dev/null +++ b/test/message/test_runner_spec_reporter_successful.out @@ -0,0 +1,9 @@ +* should pass *(*ms)* +*tests 1* +*suites 0* +*pass 1* +*fail 0* +*cancelled 0* +*skipped 0* +*todo 0* +*duration_ms *