| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,6 +58,8 @@ if (shardOption) { | |||
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | run({ concurrency, inspectPort, watch: getOptionValue('--watch'), setup: setupTestReporters, shard }) | |
| 61 | - .once('test:fail', () => { | ||
| 62 | - process.exitCode = kGenericUserError; | ||
| 61 | + .on('test:fail', (data) => { | ||
| 62 | + if (data.todo === undefined || data.todo === false) { | ||
| 63 | + process.exitCode = kGenericUserError; | ||
| 64 | + } | ||
| 63 | 65 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,8 +191,10 @@ let reportersSetup; | |||
| 191 | 191 | function getGlobalRoot() { | |
| 192 | 192 | if (!globalRoot) { | |
| 193 | 193 | globalRoot = createTestTree(); | |
| 194 | - globalRoot.reporter.once('test:fail', () => { | ||
| 195 | - process.exitCode = kGenericUserError; | ||
| 194 | + globalRoot.reporter.on('test:fail', (data) => { | ||
| 195 | + if (data.todo === undefined || data.todo === false) { | ||
| 196 | + process.exitCode = kGenericUserError; | ||
| 197 | + } | ||
| 196 | 198 | }); | |
| 197 | 199 | reportersSetup = setupTestReporters(globalRoot); | |
| 198 | 200 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -282,8 +282,8 @@ class Test extends AsyncResource { | |||
| 282 | 282 | this.harness = null; // Configured on the root test by the test harness. | |
| 283 | 283 | this.mock = null; | |
| 284 | 284 | this.cancelled = false; | |
| 285 | - this.skipped = !!skip; | ||
| 286 | - this.isTodo = !!todo; | ||
| 285 | + this.skipped = skip !== undefined && skip !== false; | ||
| 286 | + this.isTodo = todo !== undefined && todo !== false; | ||
| 287 | 287 | this.startTime = null; | |
| 288 | 288 | this.endTime = null; | |
| 289 | 289 | this.passed = false; | |
@@ -634,7 +634,7 @@ class Test extends AsyncResource { | |||
| 634 | 634 | subtest.#cancel(pendingSubtestsError); | |
| 635 | 635 | subtest.postRun(pendingSubtestsError); | |
| 636 | 636 | } | |
| 637 | - if (!subtest.passed) { | ||
| 637 | + if (!subtest.passed && !subtest.isTodo) { | ||
| 638 | 638 | failed++; | |
| 639 | 639 | } | |
| 640 | 640 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + const { describe, test } = require('node:test'); | ||
| 2 | + | ||
| 3 | + describe('suite should pass', () => { | ||
| 4 | + test.todo('should fail without harming suite', () => { | ||
| 5 | + throw new Error('Fail but not badly') | ||
| 6 | + }); | ||
| 7 | + }); | ||
| 8 | + | ||
| 9 | + test.todo('should fail without effecting exit code', () => { | ||
| 10 | + throw new Error('Fail but not badly') | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + test('empty string todo', { todo: '' }, () => { | ||
| 14 | + throw new Error('Fail but not badly') | ||
| 15 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,6 +47,19 @@ if (process.argv[2] === 'child') { | |||
| 47 | 47 | assert.strictEqual(child.status, 0); | |
| 48 | 48 | assert.strictEqual(child.signal, null); | |
| 49 | 49 | ||
| 50 | + | ||
| 51 | + child = spawnSync(process.execPath, [ | ||
| 52 | + '--test', | ||
| 53 | + fixtures.path('test-runner', 'todo_exit_code.js'), | ||
| 54 | + ]); | ||
| 55 | + assert.strictEqual(child.status, 0); | ||
| 56 | + assert.strictEqual(child.signal, null); | ||
| 57 | + const stdout = child.stdout.toString(); | ||
| 58 | + assert.match(stdout, /# tests 3/); | ||
| 59 | + assert.match(stdout, /# pass 0/); | ||
| 60 | + assert.match(stdout, /# fail 0/); | ||
| 61 | + assert.match(stdout, /# todo 3/); | ||
| 62 | + | ||
| 50 | 63 | child = spawnSync(process.execPath, [__filename, 'child', 'fail']); | |
| 51 | 64 | assert.strictEqual(child.status, 1); | |
| 52 | 65 | assert.strictEqual(child.signal, null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments