Skip to content

Commit 2262653

Browse files
committed
test_runner: apply runOnly on suites
PR-URL: #48279 Fixes: #47937 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 9d4025c commit 2262653

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/internal/test_runner/test.js

+2
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,8 @@ class Suite extends Test {
759759
constructor(options) {
760760
super(options);
761761

762+
this.runOnlySubtests = testOnlyFlag;
763+
762764
try {
763765
const { ctx, args } = this.getRunArgs();
764766
const runArgs = [this.fn, ctx];

test/fixtures/test-runner/output/only_tests.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ test('only = true, with subtests', { only: true }, async (t) => {
4848
});
4949

5050
describe.only('describe only = true, with subtests', () => {
51-
it('`it` subtest 1 should run', () => {});
51+
it.only('`it` subtest 1 should run', () => {});
5252

53-
it('`it` subtest 2 should run', async () => {});
53+
it('`it` subtest 2 should not run', async () => {});
5454
});
5555

5656
describe.only('describe only = true, with a mixture of subtests', () => {
@@ -92,9 +92,9 @@ describe.only('describe only = true, with a mixture of subtests', () => {
9292
});
9393

9494
describe.only('describe only = true, with subtests', () => {
95-
test('subtest should run', () => {});
95+
test.only('subtest should run', () => {});
9696

97-
test('async subtest should run', async () => {});
97+
test('async subtest should not run', async () => {});
9898

9999
test('subtest should be skipped', { only: false }, () => {});
100100
});

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ ok 11 - only = true, with subtests
122122
---
123123
duration_ms: *
124124
...
125-
# Subtest: `it` subtest 2 should run
126-
ok 2 - `it` subtest 2 should run
125+
# Subtest: `it` subtest 2 should not run
126+
ok 2 - `it` subtest 2 should not run # SKIP 'only' option not set
127127
---
128128
duration_ms: *
129129
...
@@ -155,7 +155,7 @@ ok 12 - describe only = true, with subtests
155155
duration_ms: *
156156
...
157157
# Subtest: `it` subtest 3 skip
158-
ok 5 - `it` subtest 3 skip # SKIP
158+
ok 5 - `it` subtest 3 skip # SKIP 'only' option not set
159159
---
160160
duration_ms: *
161161
...
@@ -185,7 +185,7 @@ ok 12 - describe only = true, with subtests
185185
duration_ms: *
186186
...
187187
# Subtest: `test` subtest 3 skip
188-
ok 11 - `test` subtest 3 skip # SKIP
188+
ok 11 - `test` subtest 3 skip # SKIP 'only' option not set
189189
---
190190
duration_ms: *
191191
...
@@ -206,8 +206,8 @@ ok 13 - describe only = true, with a mixture of subtests
206206
---
207207
duration_ms: *
208208
...
209-
# Subtest: async subtest should run
210-
ok 2 - async subtest should run
209+
# Subtest: async subtest should not run
210+
ok 2 - async subtest should not run # SKIP 'only' option not set
211211
---
212212
duration_ms: *
213213
...
@@ -225,9 +225,9 @@ ok 14 - describe only = true, with subtests
225225
1..14
226226
# tests 40
227227
# suites 3
228-
# pass 17
228+
# pass 15
229229
# fail 0
230230
# cancelled 0
231-
# skipped 23
231+
# skipped 25
232232
# todo 0
233233
# duration_ms *

0 commit comments

Comments
 (0)