mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test_runner: fix todo and only in spec reporter
PR-URL: https://github.com/nodejs/node/pull/48929 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
9f122be15a
commit
d217435cd3
5 files changed
+43
-37
No files matched your search
@@ -64,17 +64,24 @@ class SpecReporter extends Transform {
|
||||
), `\n${indent} `);
|
||||
return `\n${indent} ${message}\n`;
|
||||
}
|
||||
#formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, skippedSubtest = false) {
|
||||
#formatTestReport(type, data, prefix = '', indent = '', hasChildren = false) {
|
||||
let color = colors[type] ?? white;
|
||||
let symbol = symbols[type] ?? ' ';
|
||||
const { skip, todo } = data;
|
||||
const duration_ms = data.details?.duration_ms ? ` ${gray}(${data.details.duration_ms}ms)${white}` : '';
|
||||
const title = `${data.name}${duration_ms}${skippedSubtest ? ' # SKIP' : ''}`;
|
||||
let title = `${data.name}${duration_ms}`;
|
||||
|
||||
if (skip !== undefined) {
|
||||
title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`;
|
||||
} else if (todo !== undefined) {
|
||||
title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`;
|
||||
}
|
||||
if (hasChildren) {
|
||||
// If this test has had children - it was already reported, so slightly modify the output
|
||||
return `${prefix}${indent}${color}${symbols['arrow:right']}${white}${title}\n`;
|
||||
}
|
||||
const error = this.#formatError(data.details?.error, indent);
|
||||
if (skippedSubtest) {
|
||||
if (skip !== undefined) {
|
||||
color = gray;
|
||||
symbol = symbols['hyphen:minus'];
|
||||
}
|
||||
@@ -101,9 +108,8 @@ class SpecReporter extends Transform {
|
||||
ArrayPrototypeShift(this.#reported);
|
||||
hasChildren = true;
|
||||
}
|
||||
const skippedSubtest = subtest && data.skip && data.skip !== undefined;
|
||||
const indent = this.#indent(data.nesting);
|
||||
return `${this.#formatTestReport(type, data, prefix, indent, hasChildren, skippedSubtest)}\n`;
|
||||
return `${this.#formatTestReport(type, data, prefix, indent, hasChildren)}\n`;
|
||||
}
|
||||
#handleEvent({ type, data }) {
|
||||
switch (type) {
|
||||
|
||||
+4
-4
@@ -13,12 +13,12 @@ it.todo('sync pass todo', () => {
|
||||
it('sync pass todo with message', { todo: 'this is a passing todo' }, () => {
|
||||
});
|
||||
|
||||
it.todo('sync fail todo', () => {
|
||||
throw new Error('thrown from sync fail todo');
|
||||
it.todo('sync todo', () => {
|
||||
throw new Error('should not count as a failure');
|
||||
});
|
||||
|
||||
it('sync fail todo with message', { todo: 'this is a failing todo' }, () => {
|
||||
throw new Error('thrown from sync fail todo with message');
|
||||
it('sync todo with message', { todo: 'this is a failing todo' }, () => {
|
||||
throw new Error('should not count as a failure');
|
||||
});
|
||||
|
||||
it.skip('sync skip pass', () => {
|
||||
|
||||
+6
-6
@@ -9,12 +9,12 @@ ok 2 - sync pass todo with message # TODO this is a passing todo
|
||||
---
|
||||
duration_ms: *
|
||||
...
|
||||
# Subtest: sync fail todo
|
||||
not ok 3 - sync fail todo # TODO
|
||||
# Subtest: sync todo
|
||||
not ok 3 - sync todo # TODO
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'testCodeFailure'
|
||||
error: 'thrown from sync fail todo'
|
||||
error: 'should not count as a failure'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -25,12 +25,12 @@ not ok 3 - sync fail todo # TODO
|
||||
*
|
||||
*
|
||||
...
|
||||
# Subtest: sync fail todo with message
|
||||
not ok 4 - sync fail todo with message # TODO this is a failing todo
|
||||
# Subtest: sync todo with message
|
||||
not ok 4 - sync todo with message # TODO this is a failing todo
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'testCodeFailure'
|
||||
error: 'thrown from sync fail todo with message'
|
||||
error: 'should not count as a failure'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
sync pass todo (*ms)
|
||||
sync pass todo with message (*ms)
|
||||
sync fail todo (*ms)
|
||||
sync pass todo (*ms) # TODO
|
||||
sync pass todo with message (*ms) # this is a passing todo
|
||||
sync fail todo (*ms) # TODO
|
||||
Error: thrown from sync fail todo
|
||||
*
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
sync fail todo with message (*ms)
|
||||
sync fail todo with message (*ms) # this is a failing todo
|
||||
Error: thrown from sync fail todo with message
|
||||
*
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
*
|
||||
|
||||
sync skip pass (*ms) # SKIP
|
||||
sync skip pass with message (*ms) # SKIP
|
||||
sync skip pass with message (*ms) # this is skipped
|
||||
sync pass (*ms)
|
||||
this test should pass
|
||||
sync throw fail (*ms)
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
invalid subtest - pass but subtest fails (*ms)
|
||||
sync skip option (*ms) # SKIP
|
||||
sync skip option with message (*ms) # SKIP
|
||||
sync skip option with message (*ms) # this is skipped
|
||||
sync skip option is false fail (*ms)
|
||||
Error: this should be executed
|
||||
*
|
||||
@@ -151,8 +151,8 @@
|
||||
functionAndOptions (*ms) # SKIP
|
||||
escaped description \ # \#\
|
||||
(*ms)
|
||||
escaped skip message (*ms) # SKIP
|
||||
escaped todo message (*ms)
|
||||
escaped skip message (*ms) # #skip
|
||||
escaped todo message (*ms) # #todo
|
||||
escaped diagnostic (*ms)
|
||||
#diagnostic
|
||||
callback pass (*ms)
|
||||
@@ -307,7 +307,7 @@
|
||||
|
||||
failing tests:
|
||||
|
||||
sync fail todo (*ms)
|
||||
sync fail todo (*ms) # TODO
|
||||
Error: thrown from sync fail todo
|
||||
*
|
||||
*
|
||||
@@ -317,7 +317,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
sync fail todo with message (*ms)
|
||||
sync fail todo with message (*ms) # this is a failing todo
|
||||
Error: thrown from sync fail todo with message
|
||||
*
|
||||
*
|
||||
@@ -347,7 +347,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
async skip fail (*ms)
|
||||
async skip fail (*ms) # SKIP
|
||||
Error: thrown from async throw fail
|
||||
*
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
sync pass todo (*ms)
|
||||
sync pass todo with message (*ms)
|
||||
sync fail todo (*ms)
|
||||
sync pass todo (*ms) # TODO
|
||||
sync pass todo with message (*ms) # this is a passing todo
|
||||
sync fail todo (*ms) # TODO
|
||||
Error: thrown from sync fail todo
|
||||
*
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
sync fail todo with message (*ms)
|
||||
sync fail todo with message (*ms) # this is a failing todo
|
||||
Error: thrown from sync fail todo with message
|
||||
*
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
*
|
||||
|
||||
sync skip pass (*ms) # SKIP
|
||||
sync skip pass with message (*ms) # SKIP
|
||||
sync skip pass with message (*ms) # this is skipped
|
||||
sync pass (*ms)
|
||||
this test should pass
|
||||
sync throw fail (*ms)
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
invalid subtest - pass but subtest fails (*ms)
|
||||
sync skip option (*ms) # SKIP
|
||||
sync skip option with message (*ms) # SKIP
|
||||
sync skip option with message (*ms) # this is skipped
|
||||
sync skip option is false fail (*ms)
|
||||
Error: this should be executed
|
||||
*
|
||||
@@ -151,8 +151,8 @@
|
||||
functionAndOptions (*ms) # SKIP
|
||||
escaped description \ # \#\
|
||||
(*ms)
|
||||
escaped skip message (*ms) # SKIP
|
||||
escaped todo message (*ms)
|
||||
escaped skip message (*ms) # #skip
|
||||
escaped todo message (*ms) # #todo
|
||||
escaped diagnostic (*ms)
|
||||
#diagnostic
|
||||
callback pass (*ms)
|
||||
@@ -307,7 +307,7 @@
|
||||
|
||||
failing tests:
|
||||
|
||||
sync fail todo (*ms)
|
||||
sync fail todo (*ms) # TODO
|
||||
Error: thrown from sync fail todo
|
||||
*
|
||||
*
|
||||
@@ -317,7 +317,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
sync fail todo with message (*ms)
|
||||
sync fail todo with message (*ms) # this is a failing todo
|
||||
Error: thrown from sync fail todo with message
|
||||
*
|
||||
*
|
||||
@@ -347,7 +347,7 @@
|
||||
*
|
||||
*
|
||||
|
||||
async skip fail (*ms)
|
||||
async skip fail (*ms) # SKIP
|
||||
Error: thrown from async throw fail
|
||||
*
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user