Skip to content

Commit dcdb259

Browse files
MoLowtargos
authored andcommitted
test_runner: fix todo inheritance
PR-URL: #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>
1 parent 2cd6a3b commit dcdb259

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

lib/internal/test_runner/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class Test extends AsyncResource {
647647
this.expectedAssertions = plan;
648648
this.cancelled = false;
649649
this.skipped = skip !== undefined && skip !== false;
650-
this.isTodo = todo !== undefined && todo !== false;
650+
this.isTodo = (todo !== undefined && todo !== false) || this.parent?.isTodo;
651651
this.startTime = null;
652652
this.endTime = null;
653653
this.passed = false;

test/fixtures/test-runner/output/name_pattern.snapshot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ ok 9 - no
146146
...
147147
# Subtest: no with todo
148148
# Subtest: yes
149-
ok 1 - yes
149+
ok 1 - yes # TODO
150150
---
151151
duration_ms: *
152152
type: 'test'
153153
...
154154
# Subtest: maybe
155155
# Subtest: yes
156-
ok 1 - yes
156+
ok 1 - yes # TODO
157157
---
158158
duration_ms: *
159159
type: 'test'
160160
...
161161
1..1
162-
ok 2 - maybe
162+
ok 2 - maybe # TODO
163163
---
164164
duration_ms: *
165165
type: 'suite'
@@ -193,9 +193,9 @@ ok 11 - DescribeForMatchWithAncestors
193193
1..11
194194
# tests 18
195195
# suites 12
196-
# pass 16
196+
# pass 14
197197
# fail 0
198198
# cancelled 0
199199
# skipped 2
200-
# todo 0
200+
# todo 2
201201
# duration_ms *

test/fixtures/test-runner/todo_exit_code.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ test.todo('should fail without effecting exit code', () => {
1313
test('empty string todo', { todo: '' }, () => {
1414
throw new Error('Fail but not badly')
1515
});
16+
17+
describe.todo('should inherit todo', () => {
18+
test('should fail without harming suite', () => {
19+
throw new Error('Fail but not badly');
20+
});
21+
});

test/parallel/test-runner-exit-code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ if (process.argv[2] === 'child') {
5858
assert.strictEqual(child.status, 0);
5959
assert.strictEqual(child.signal, null);
6060
const stdout = child.stdout.toString();
61-
assert.match(stdout, /tests 3/);
61+
assert.match(stdout, /tests 4/);
6262
assert.match(stdout, /pass 0/);
6363
assert.match(stdout, /fail 0/);
64-
assert.match(stdout, /todo 3/);
64+
assert.match(stdout, /todo 4/);
6565

6666
child = spawnSync(process.execPath, [__filename, 'child', 'fail']);
6767
assert.strictEqual(child.status, 1);

0 commit comments

Comments
 (0)