test_runner: fix todo inheritance

PR-URL: https://github.com/nodejs/node/pull/59721
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Moshe Atlow 2025-09-04 12:35:48 +03:00 committed by GitHub
parent 3903ee8cf3
commit 2258f22672
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -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 *

View File

@ -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');
});
});

View File

@ -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);