Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: fix todo and skip messages on spec-reporter #47525

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Comment on lines 116 to +121
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:pass':
case 'test:skip':
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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this.

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) {
Comment on lines +35 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix indentation

this.#emit('test:pass', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
}

Expand Down