Skip to content

Commit

Permalink
test_runner: display skipped tests in spec reporter output
Browse files Browse the repository at this point in the history
PR-URL: #46651
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
richiemccoll authored and targos committed Mar 13, 2023
1 parent 75e4325 commit 66016e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
14 changes: 10 additions & 4 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const symbols = {
'test:pass': '\u2714 ',
'test:diagnostic': '\u2139 ',
'arrow:right': '\u25B6 ',
'hyphen:minus': '\uFE63 ',
};
class SpecReporter extends Transform {
#stack = [];
Expand Down Expand Up @@ -60,8 +61,8 @@ class SpecReporter extends Transform {
return `\n${indent} ${message}\n`;
}
#handleEvent({ type, data }) {
const color = colors[type] ?? white;
const symbol = symbols[type] ?? ' ';
let color = colors[type] ?? white;
let symbol = symbols[type] ?? ' ';

switch (type) {
case 'test:fail':
Expand All @@ -81,15 +82,20 @@ class SpecReporter extends Transform {
ArrayPrototypeUnshift(this.#reported, msg);
prefix += `${this.#indent(msg.nesting)}${symbols['arrow:right']}${msg.name}\n`;
}
const skippedSubtest = subtest && data.skip && data.skip !== undefined;
const indent = this.#indent(data.nesting);
const duration_ms = data.details?.duration_ms ? ` ${gray}(${data.details.duration_ms}ms)${white}` : '';
const title = `${data.name}${duration_ms}`;
const title = `${data.name}${duration_ms}${skippedSubtest ? ' # SKIP' : ''}`;
if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) {
// If this test has had children - it was already reporter, so slightly modify the output
// If this test has had children - it was already reported, so slightly modify the output
ArrayPrototypeShift(this.#reported);
return `${prefix}${indent}${color}${symbols['arrow:right']}${white}${title}\n\n`;
}
const error = this.#formatError(data.details?.error, indent);
if (skippedSubtest) {
color = gray;
symbol = symbols['hyphen:minus'];
}
return `${prefix}${indent}${color}${symbol}${title}${error}${white}\n`;
}
case 'test:start':
Expand Down
20 changes: 10 additions & 10 deletions test/message/test_runner_output_spec_reporter.out
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*
*

sync skip pass (*ms)
sync skip pass with message (*ms)
sync skip pass (*ms) # SKIP
sync skip pass with message (*ms) # SKIP
sync pass (*ms)
this test should pass
sync throw fail (*ms)
Expand All @@ -34,7 +34,7 @@
*
*

async skip pass (*ms)
async skip pass (*ms) # SKIP
async pass (*ms)
async throw fail (*ms)
Error: thrown from async throw fail
Expand All @@ -46,7 +46,7 @@
*
*

async skip fail (*ms)
async skip fail (*ms) # SKIP
Error: thrown from async throw fail
*
*
Expand Down Expand Up @@ -129,8 +129,8 @@
top level (*ms)

invalid subtest - pass but subtest fails (*ms)
sync skip option (*ms)
sync skip option with message (*ms)
sync skip option (*ms) # SKIP
sync skip option with message (*ms) # SKIP
sync skip option is false fail (*ms)
Error: this should be executed
*
Expand All @@ -146,13 +146,13 @@
<anonymous> (*ms)
test with only a name provided (*ms)
<anonymous> (*ms)
<anonymous> (*ms)
test with a name and options provided (*ms)
functionAndOptions (*ms)
<anonymous> (*ms) # SKIP
test with a name and options provided (*ms) # SKIP
functionAndOptions (*ms) # SKIP
escaped description \ # *
*
(*ms)
escaped skip message (*ms)
escaped skip message (*ms) # SKIP
escaped todo message (*ms)
escaped diagnostic (*ms)
#diagnostic
Expand Down

0 comments on commit 66016e2

Please sign in to comment.