| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,8 @@ if (shardOption) { | |||
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | 59 | run({ concurrency, inspectPort, watch: getOptionValue('--watch'), setup: setupTestReporters, shard }) | |
| 60 | - .once('test:fail', () => { | ||
| 61 | - process.exitCode = 1; | ||
| 60 | + .on('test:fail', (data) => { | ||
| 61 | + if (data.todo === undefined || data.todo === false) { | ||
| 62 | + process.exitCode = 1; | ||
| 63 | + } | ||
| 62 | 64 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,8 +189,10 @@ let reportersSetup; | |||
| 189 | 189 | function getGlobalRoot() { | |
| 190 | 190 | if (!globalRoot) { | |
| 191 | 191 | globalRoot = createTestTree(); | |
| 192 | - globalRoot.reporter.once('test:fail', () => { | ||
| 193 | - process.exitCode = 1; | ||
| 192 | + globalRoot.reporter.on('test:fail', (data) => { | ||
| 193 | + if (data.todo === undefined || data.todo === false) { | ||
| 194 | + process.exitCode = 1; | ||
| 195 | + } | ||
| 194 | 196 | }); | |
| 195 | 197 | reportersSetup = setupTestReporters(globalRoot); | |
| 196 | 198 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -311,8 +311,8 @@ class Test extends AsyncResource { | |||
| 311 | 311 | this.harness = null; // Configured on the root test by the test harness. | |
| 312 | 312 | this.mock = null; | |
| 313 | 313 | this.cancelled = false; | |
| 314 | - this.skipped = !!skip; | ||
| 315 | - this.isTodo = !!todo; | ||
| 314 | + this.skipped = skip !== undefined && skip !== false; | ||
| 315 | + this.isTodo = todo !== undefined && todo !== false; | ||
| 316 | 316 | this.startTime = null; | |
| 317 | 317 | this.endTime = null; | |
| 318 | 318 | this.passed = false; | |
@@ -667,7 +667,7 @@ class Test extends AsyncResource { | |||
| 667 | 667 | subtest.#cancel(pendingSubtestsError); | |
| 668 | 668 | subtest.postRun(pendingSubtestsError); | |
| 669 | 669 | } | |
| 670 | - if (!subtest.passed) { | ||
| 670 | + if (!subtest.passed && !subtest.isTodo) { | ||
| 671 | 671 | failed++; | |
| 672 | 672 | } | |
| 673 | 673 | } | |
| 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 | |
|---|---|---|---|
@@ -50,6 +50,19 @@ if (process.argv[2] === 'child') { | |||
| 50 | 50 | assert.strictEqual(child.status, 0); | |
| 51 | 51 | assert.strictEqual(child.signal, null); | |
| 52 | 52 | ||
| 53 | + | ||
| 54 | + child = spawnSync(process.execPath, [ | ||
| 55 | + '--test', | ||
| 56 | + fixtures.path('test-runner', 'todo_exit_code.js'), | ||
| 57 | + ]); | ||
| 58 | + assert.strictEqual(child.status, 0); | ||
| 59 | + assert.strictEqual(child.signal, null); | ||
| 60 | + const stdout = child.stdout.toString(); | ||
| 61 | + assert.match(stdout, /# tests 3/); | ||
| 62 | + assert.match(stdout, /# pass 0/); | ||
| 63 | + assert.match(stdout, /# fail 0/); | ||
| 64 | + assert.match(stdout, /# todo 3/); | ||
| 65 | + | ||
| 53 | 66 | child = spawnSync(process.execPath, [__filename, 'child', 'fail']); | |
| 54 | 67 | assert.strictEqual(child.status, 1); | |
| 55 | 68 | assert.strictEqual(child.signal, null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments