Skip to content

Commit

Permalink
test_runner: hide failing tests title when all tests pass
Browse files Browse the repository at this point in the history
PR-URL: #47370
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
MoLow authored and RafaelGSS committed Apr 8, 2023
1 parent eb837ce commit 463361e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions test/message/test_runner_spec_reporter_successful.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Flags: --no-warnings --test-reporter=spec
'use strict';
require('../common');
const { it } = require('node:test');

it('should pass', () => {});
9 changes: 9 additions & 0 deletions test/message/test_runner_spec_reporter_successful.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* should pass *(*ms)*
*tests 1*
*suites 0*
*pass 1*
*fail 0*
*cancelled 0*
*skipped 0*
*todo 0*
*duration_ms *

0 comments on commit 463361e

Please sign in to comment.