diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 8e189b62cad817..d62421f7b42e15 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -647,7 +647,7 @@ class Test extends AsyncResource { this.expectedAssertions = plan; this.cancelled = false; this.skipped = skip !== undefined && skip !== false; - this.isTodo = todo !== undefined && todo !== false; + this.isTodo = (todo !== undefined && todo !== false) || this.parent?.isTodo; this.startTime = null; this.endTime = null; this.passed = false; diff --git a/test/fixtures/test-runner/output/name_pattern.snapshot b/test/fixtures/test-runner/output/name_pattern.snapshot index e965b470730488..80f310ad268eac 100644 --- a/test/fixtures/test-runner/output/name_pattern.snapshot +++ b/test/fixtures/test-runner/output/name_pattern.snapshot @@ -146,20 +146,20 @@ ok 9 - no ... # Subtest: no with todo # Subtest: yes - ok 1 - yes + ok 1 - yes # TODO --- duration_ms: * type: 'test' ... # Subtest: maybe # Subtest: yes - ok 1 - yes + ok 1 - yes # TODO --- duration_ms: * type: 'test' ... 1..1 - ok 2 - maybe + ok 2 - maybe # TODO --- duration_ms: * type: 'suite' @@ -193,9 +193,9 @@ ok 11 - DescribeForMatchWithAncestors 1..11 # tests 18 # suites 12 -# pass 16 +# pass 14 # fail 0 # cancelled 0 # skipped 2 -# todo 0 +# todo 2 # duration_ms * diff --git a/test/fixtures/test-runner/todo_exit_code.js b/test/fixtures/test-runner/todo_exit_code.js index 6577eefe52f7dc..77f519058e9760 100644 --- a/test/fixtures/test-runner/todo_exit_code.js +++ b/test/fixtures/test-runner/todo_exit_code.js @@ -13,3 +13,9 @@ test.todo('should fail without effecting exit code', () => { test('empty string todo', { todo: '' }, () => { throw new Error('Fail but not badly') }); + +describe.todo('should inherit todo', () => { + test('should fail without harming suite', () => { + throw new Error('Fail but not badly'); + }); +}); diff --git a/test/parallel/test-runner-exit-code.js b/test/parallel/test-runner-exit-code.js index d2f0251e5fb30c..792c5f1717bd60 100644 --- a/test/parallel/test-runner-exit-code.js +++ b/test/parallel/test-runner-exit-code.js @@ -58,10 +58,10 @@ if (process.argv[2] === 'child') { assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); const stdout = child.stdout.toString(); - assert.match(stdout, /tests 3/); + assert.match(stdout, /tests 4/); assert.match(stdout, /pass 0/); assert.match(stdout, /fail 0/); - assert.match(stdout, /todo 3/); + assert.match(stdout, /todo 4/); child = spawnSync(process.execPath, [__filename, 'child', 'fail']); assert.strictEqual(child.status, 1);