Skip to content

Commit cecf5df

Browse files
committed
fix reporter when without --test
1 parent 57caf13 commit cecf5df

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

lib/internal/test_runner/reporter/spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ const colors = {
2323
'__proto__': null,
2424
'test:fail': red,
2525
'test:pass': green,
26+
'test:todo': blue,
27+
'test:skip': gray,
2628
'test:diagnostic': blue,
2729
};
2830
const symbols = {
2931
'__proto__': null,
3032
'test:fail': '\u2716 ',
3133
'test:pass': '\u2714 ',
34+
'test:skip': '\u002D ',
35+
'test:todo': '\u25A1 ',
3236
'test:diagnostic': '\u2139 ',
3337
'test:coverage': '\u2139 ',
3438
'arrow:right': '\u25B6 ',
@@ -111,6 +115,10 @@ class SpecReporter extends Transform {
111115
return this.#handleTestReportEvent(type, data);
112116
case 'test:pass':
113117
return this.#handleTestReportEvent(type, data);
118+
case 'test:skip':
119+
return this.#handleTestReportEvent(type, data);
120+
case 'test:todo':
121+
return this.#handleTestReportEvent(type, data);
114122
case 'test:start':
115123
ArrayPrototypeUnshift(this.#stack, { __proto__: null, data, type });
116124
break;

lib/internal/test_runner/test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,14 @@ class Test extends AsyncResource {
691691
details.type = this.reportedType;
692692
}
693693

694-
if (this.passed) {
695-
this.reporter.ok(this.nesting, kFilename, this.testNumber, this.name, details, directive);
694+
if(this.skipped) {
695+
this.reporter.skip(this.nesting, kFilename, this.testNumber, this.name, details, directive);
696+
}
697+
else if (this.isTodo) {
698+
this.reporter.todo(this.nesting, kFilename, this.testNumber, this.name, details, directive);
699+
}
700+
else if (this.passed) {
701+
this.reporter.ok(this.nesting, kFilename, this.testNumber, this.name, details, directive);
696702
} else {
697703
details.error = this.error;
698704
this.reporter.fail(this.nesting, kFilename, this.testNumber, this.name, details, directive);

lib/internal/test_runner/tests_stream.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const {
33
ArrayPrototypePush,
44
ArrayPrototypeShift,
55
} = primordials;
6+
const console = require('console')
67
const Readable = require('internal/streams/readable');
78

89
class TestsStream extends Readable {
@@ -31,7 +32,15 @@ class TestsStream extends Readable {
3132
this.#emit('test:fail', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
3233
}
3334

34-
ok(nesting, file, testNumber, name, details, directive) {
35+
skip(nesting, file, testNumber, name, details, directive) {
36+
this.#emit('test:skip', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
37+
}
38+
39+
todo(nesting, file, testNumber, name, details, directive) {
40+
this.#emit('test:todo', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
41+
}
42+
43+
ok(nesting, file, testNumber, name, details, directive) {
3544
this.#emit('test:pass', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
3645
}
3746

0 commit comments

Comments
 (0)