From cecf5dfc58112588e4300ab3d83f7cb3e927ac3e Mon Sep 17 00:00:00 2001 From: Erick Wendel Date: Wed, 12 Apr 2023 16:30:24 +0200 Subject: [PATCH] fix reporter when without --test --- lib/internal/test_runner/reporter/spec.js | 8 ++++++++ lib/internal/test_runner/test.js | 10 ++++++++-- lib/internal/test_runner/tests_stream.js | 11 ++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/reporter/spec.js b/lib/internal/test_runner/reporter/spec.js index ecc20bb866a784..b791786c7c4b4b 100644 --- a/lib/internal/test_runner/reporter/spec.js +++ b/lib/internal/test_runner/reporter/spec.js @@ -23,12 +23,16 @@ const colors = { '__proto__': null, 'test:fail': red, 'test:pass': green, + 'test:todo': blue, + 'test:skip': gray, 'test:diagnostic': blue, }; const symbols = { '__proto__': null, 'test:fail': '\u2716 ', 'test:pass': '\u2714 ', + 'test:skip': '\u002D ', + 'test:todo': '\u25A1 ', 'test:diagnostic': '\u2139 ', 'test:coverage': '\u2139 ', 'arrow:right': '\u25B6 ', @@ -111,6 +115,10 @@ class SpecReporter extends Transform { return this.#handleTestReportEvent(type, data); case 'test:pass': return this.#handleTestReportEvent(type, data); + case 'test:skip': + return this.#handleTestReportEvent(type, data); + case 'test:todo': + return this.#handleTestReportEvent(type, data); case 'test:start': ArrayPrototypeUnshift(this.#stack, { __proto__: null, data, type }); break; diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index c1203c91177f43..3fe094aa8daf9a 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -691,8 +691,14 @@ class Test extends AsyncResource { details.type = this.reportedType; } - if (this.passed) { - this.reporter.ok(this.nesting, kFilename, this.testNumber, this.name, details, directive); + if(this.skipped) { + this.reporter.skip(this.nesting, kFilename, this.testNumber, this.name, details, directive); + } + else if (this.isTodo) { + this.reporter.todo(this.nesting, kFilename, this.testNumber, this.name, details, directive); + } + else if (this.passed) { + this.reporter.ok(this.nesting, kFilename, this.testNumber, this.name, details, directive); } else { details.error = this.error; this.reporter.fail(this.nesting, kFilename, this.testNumber, this.name, details, directive); diff --git a/lib/internal/test_runner/tests_stream.js b/lib/internal/test_runner/tests_stream.js index c32d57d3b4cf71..1b784bfed5c1be 100644 --- a/lib/internal/test_runner/tests_stream.js +++ b/lib/internal/test_runner/tests_stream.js @@ -3,6 +3,7 @@ const { ArrayPrototypePush, ArrayPrototypeShift, } = primordials; +const console = require('console') const Readable = require('internal/streams/readable'); class TestsStream extends Readable { @@ -31,7 +32,15 @@ class TestsStream extends Readable { this.#emit('test:fail', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); } - ok(nesting, file, testNumber, name, details, directive) { + skip(nesting, file, testNumber, name, details, directive) { + this.#emit('test:skip', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); + } + + todo(nesting, file, testNumber, name, details, directive) { + this.#emit('test:todo', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); + } + + ok(nesting, file, testNumber, name, details, directive) { this.#emit('test:pass', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); }