Skip to content

Commit

Permalink
fix reporter when without --test
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickWendel committed Apr 12, 2023
1 parent 57caf13 commit cecf5df
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion lib/internal/test_runner/tests_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
ArrayPrototypePush,
ArrayPrototypeShift,
} = primordials;
const console = require('console')
const Readable = require('internal/streams/readable');

class TestsStream extends Readable {
Expand Down Expand Up @@ -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 });
}

Expand Down

0 comments on commit cecf5df

Please sign in to comment.