GeezerVison is showing github.com — test_runner: fix todo and only in spec reporter · nodejs/node@d217435
File treeExpand file treeCollapse file tree Open diff view settings lib/internal/test_runner/reporter test/fixtures/test-runner/output
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/test_runner/reporter/spec.js +11-5Lines changed: 11 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,17 +64,24 @@ class SpecReporter extends Transform { | 64 | 64 | ), `\n${indent} `); | 65 | 65 | return `\n${indent} ${message}\n`; | 66 | 66 | } | 67 | | - #formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, skippedSubtest = false) { | | 67 | + #formatTestReport(type, data, prefix = '', indent = '', hasChildren = false) { | 68 | 68 | let color = colors[type] ?? white; | 69 | 69 | let symbol = symbols[type] ?? ' '; | | 70 | + const { skip, todo } = data; | 70 | 71 | const duration_ms = data.details?.duration_ms ? ` ${gray}(${data.details.duration_ms}ms)${white}` : ''; | 71 | | - const title = `${data.name}${duration_ms}${skippedSubtest ? ' # SKIP' : ''}`; | | 72 | + let title = `${data.name}${duration_ms}`; | | 73 | + | | 74 | + if (skip !== undefined) { | | 75 | + title += ` # ${typeof skip === 'string' && skip.length ? skip : 'SKIP'}`; | | 76 | + } else if (todo !== undefined) { | | 77 | + title += ` # ${typeof todo === 'string' && todo.length ? todo : 'TODO'}`; | | 78 | + } | 72 | 79 | if (hasChildren) { | 73 | 80 | // If this test has had children - it was already reported, so slightly modify the output | 74 | 81 | return `${prefix}${indent}${color}${symbols['arrow:right']}${white}${title}\n`; | 75 | 82 | } | 76 | 83 | const error = this.#formatError(data.details?.error, indent); | 77 | | - if (skippedSubtest) { | | 84 | + if (skip !== undefined) { | 78 | 85 | color = gray; | 79 | 86 | symbol = symbols['hyphen:minus']; | 80 | 87 | } | @@ -101,9 +108,8 @@ class SpecReporter extends Transform { | 101 | 108 | ArrayPrototypeShift(this.#reported); | 102 | 109 | hasChildren = true; | 103 | 110 | } | 104 | | - const skippedSubtest = subtest && data.skip && data.skip !== undefined; | 105 | 111 | const indent = this.#indent(data.nesting); | 106 | | - return `${this.#formatTestReport(type, data, prefix, indent, hasChildren, skippedSubtest)}\n`; | | 112 | + return `${this.#formatTestReport(type, data, prefix, indent, hasChildren)}\n`; | 107 | 113 | } | 108 | 114 | #handleEvent({ type, data }) { | 109 | 115 | switch (type) { | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/describe_it.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,12 +13,12 @@ it.todo('sync pass todo', () => { | 13 | 13 | it('sync pass todo with message', { todo: 'this is a passing todo' }, () => { | 14 | 14 | }); | 15 | 15 |
| 16 | | -it.todo('sync fail todo', () => { | 17 | | - throw new Error('thrown from sync fail todo'); | | 16 | +it.todo('sync todo', () => { | | 17 | + throw new Error('should not count as a failure'); | 18 | 18 | }); | 19 | 19 |
| 20 | | -it('sync fail todo with message', { todo: 'this is a failing todo' }, () => { | 21 | | - throw new Error('thrown from sync fail todo with message'); | | 20 | +it('sync todo with message', { todo: 'this is a failing todo' }, () => { | | 21 | + throw new Error('should not count as a failure'); | 22 | 22 | }); | 23 | 23 |
| 24 | 24 | it.skip('sync skip pass', () => { | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/describe_it.snapshot +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,12 +9,12 @@ ok 2 - sync pass todo with message # TODO this is a passing todo | 9 | 9 | --- | 10 | 10 | duration_ms: * | 11 | 11 | ... | 12 | | -# Subtest: sync fail todo | 13 | | -not ok 3 - sync fail todo # TODO | | 12 | +# Subtest: sync todo | | 13 | +not ok 3 - sync todo # TODO | 14 | 14 | --- | 15 | 15 | duration_ms: * | 16 | 16 | failureType: 'testCodeFailure' | 17 | | - error: 'thrown from sync fail todo' | | 17 | + error: 'should not count as a failure' | 18 | 18 | code: 'ERR_TEST_FAILURE' | 19 | 19 | stack: |- | 20 | 20 | * | @@ -25,12 +25,12 @@ not ok 3 - sync fail todo # TODO | 25 | 25 | * | 26 | 26 | * | 27 | 27 | ... | 28 | | -# Subtest: sync fail todo with message | 29 | | -not ok 4 - sync fail todo with message # TODO this is a failing todo | | 28 | +# Subtest: sync todo with message | | 29 | +not ok 4 - sync todo with message # TODO this is a failing todo | 30 | 30 | --- | 31 | 31 | duration_ms: * | 32 | 32 | failureType: 'testCodeFailure' | 33 | | - error: 'thrown from sync fail todo with message' | | 33 | + error: 'should not count as a failure' | 34 | 34 | code: 'ERR_TEST_FAILURE' | 35 | 35 | stack: |- | 36 | 36 | * | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/spec_reporter.snapshot +11-11Lines changed: 11 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | - sync pass todo (*ms) | 2 | | - sync pass todo with message (*ms) | 3 | | - sync fail todo (*ms) | | 1 | + sync pass todo (*ms) # TODO | | 2 | + sync pass todo with message (*ms) # this is a passing todo | | 3 | + sync fail todo (*ms) # TODO | 4 | 4 | Error: thrown from sync fail todo | 5 | 5 | * | 6 | 6 | * | | 10 | 10 | * | 11 | 11 | * | 12 | 12 |
| 13 | | - sync fail todo with message (*ms) | | 13 | + sync fail todo with message (*ms) # this is a failing todo | 14 | 14 | Error: thrown from sync fail todo with message | 15 | 15 | * | 16 | 16 | * | | 21 | 21 | * | 22 | 22 |
| 23 | 23 | sync skip pass (*ms) # SKIP | 24 | | - sync skip pass with message (*ms) # SKIP | | 24 | + sync skip pass with message (*ms) # this is skipped | 25 | 25 | sync pass (*ms) | 26 | 26 | this test should pass | 27 | 27 | sync throw fail (*ms) | | 130 | 130 |
| 131 | 131 | invalid subtest - pass but subtest fails (*ms) | 132 | 132 | sync skip option (*ms) # SKIP | 133 | | - sync skip option with message (*ms) # SKIP | | 133 | + sync skip option with message (*ms) # this is skipped | 134 | 134 | sync skip option is false fail (*ms) | 135 | 135 | Error: this should be executed | 136 | 136 | * | | 151 | 151 | functionAndOptions (*ms) # SKIP | 152 | 152 | escaped description \ # \#\ | 153 | 153 | (*ms) | 154 | | - escaped skip message (*ms) # SKIP | 155 | | - escaped todo message (*ms) | | 154 | + escaped skip message (*ms) # #skip | | 155 | + escaped todo message (*ms) # #todo | 156 | 156 | escaped diagnostic (*ms) | 157 | 157 | #diagnostic | 158 | 158 | callback pass (*ms) | | 307 | 307 |
| 308 | 308 | failing tests: | 309 | 309 |
| 310 | | - sync fail todo (*ms) | | 310 | + sync fail todo (*ms) # TODO | 311 | 311 | Error: thrown from sync fail todo | 312 | 312 | * | 313 | 313 | * | | 317 | 317 | * | 318 | 318 | * | 319 | 319 |
| 320 | | - sync fail todo with message (*ms) | | 320 | + sync fail todo with message (*ms) # this is a failing todo | 321 | 321 | Error: thrown from sync fail todo with message | 322 | 322 | * | 323 | 323 | * | | 347 | 347 | * | 348 | 348 | * | 349 | 349 |
| 350 | | - async skip fail (*ms) | | 350 | + async skip fail (*ms) # SKIP | 351 | 351 | Error: thrown from async throw fail | 352 | 352 | * | 353 | 353 | * | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/spec_reporter_cli.snapshot +11-11Lines changed: 11 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | - sync pass todo (*ms) | 2 | | - sync pass todo with message (*ms) | 3 | | - sync fail todo (*ms) | | 1 | + sync pass todo (*ms) # TODO | | 2 | + sync pass todo with message (*ms) # this is a passing todo | | 3 | + sync fail todo (*ms) # TODO | 4 | 4 | Error: thrown from sync fail todo | 5 | 5 | * | 6 | 6 | * | | 10 | 10 | * | 11 | 11 | * | 12 | 12 |
| 13 | | - sync fail todo with message (*ms) | | 13 | + sync fail todo with message (*ms) # this is a failing todo | 14 | 14 | Error: thrown from sync fail todo with message | 15 | 15 | * | 16 | 16 | * | | 21 | 21 | * | 22 | 22 |
| 23 | 23 | sync skip pass (*ms) # SKIP | 24 | | - sync skip pass with message (*ms) # SKIP | | 24 | + sync skip pass with message (*ms) # this is skipped | 25 | 25 | sync pass (*ms) | 26 | 26 | this test should pass | 27 | 27 | sync throw fail (*ms) | | 130 | 130 |
| 131 | 131 | invalid subtest - pass but subtest fails (*ms) | 132 | 132 | sync skip option (*ms) # SKIP | 133 | | - sync skip option with message (*ms) # SKIP | | 133 | + sync skip option with message (*ms) # this is skipped | 134 | 134 | sync skip option is false fail (*ms) | 135 | 135 | Error: this should be executed | 136 | 136 | * | | 151 | 151 | functionAndOptions (*ms) # SKIP | 152 | 152 | escaped description \ # \#\ | 153 | 153 | (*ms) | 154 | | - escaped skip message (*ms) # SKIP | 155 | | - escaped todo message (*ms) | | 154 | + escaped skip message (*ms) # #skip | | 155 | + escaped todo message (*ms) # #todo | 156 | 156 | escaped diagnostic (*ms) | 157 | 157 | #diagnostic | 158 | 158 | callback pass (*ms) | | 307 | 307 |
| 308 | 308 | failing tests: | 309 | 309 |
| 310 | | - sync fail todo (*ms) | | 310 | + sync fail todo (*ms) # TODO | 311 | 311 | Error: thrown from sync fail todo | 312 | 312 | * | 313 | 313 | * | | 317 | 317 | * | 318 | 318 | * | 319 | 319 |
| 320 | | - sync fail todo with message (*ms) | | 320 | + sync fail todo with message (*ms) # this is a failing todo | 321 | 321 | Error: thrown from sync fail todo with message | 322 | 322 | * | 323 | 323 | * | | 347 | 347 | * | 348 | 348 | * | 349 | 349 |
| 350 | | - async skip fail (*ms) | | 350 | + async skip fail (*ms) # SKIP | 351 | 351 | Error: thrown from async throw fail | 352 | 352 | * | 353 | 353 | * | |
|