Skip to content

Commit

Permalink
test_runner: apply runOnly on suites
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MoLow authored and danielleadams committed Jul 6, 2023
1 parent 632fcdb commit 45c1ea8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ class Suite extends Test {
constructor(options) {
super(options);

this.runOnlySubtests = testOnlyFlag;

try {
const { ctx, args } = this.getRunArgs();
const runArgs = [this.fn, ctx];
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/test-runner/output/only_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ test('only = true, with subtests', { only: true }, async (t) => {
});

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

it('`it` subtest 2 should run', async () => {});
it('`it` subtest 2 should not run', async () => {});
});

describe.only('describe only = true, with a mixture of subtests', () => {
Expand Down Expand Up @@ -92,9 +92,9 @@ describe.only('describe only = true, with a mixture of subtests', () => {
});

describe.only('describe only = true, with subtests', () => {
test('subtest should run', () => {});
test.only('subtest should run', () => {});

test('async subtest should run', async () => {});
test('async subtest should not run', async () => {});

test('subtest should be skipped', { only: false }, () => {});
});
16 changes: 8 additions & 8 deletions test/fixtures/test-runner/output/only_tests.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ ok 11 - only = true, with subtests
---
duration_ms: *
...
# Subtest: `it` subtest 2 should run
ok 2 - `it` subtest 2 should run
# Subtest: `it` subtest 2 should not run
ok 2 - `it` subtest 2 should not run # SKIP 'only' option not set
---
duration_ms: *
...
Expand Down Expand Up @@ -155,7 +155,7 @@ ok 12 - describe only = true, with subtests
duration_ms: *
...
# Subtest: `it` subtest 3 skip
ok 5 - `it` subtest 3 skip # SKIP
ok 5 - `it` subtest 3 skip # SKIP 'only' option not set
---
duration_ms: *
...
Expand Down Expand Up @@ -185,7 +185,7 @@ ok 12 - describe only = true, with subtests
duration_ms: *
...
# Subtest: `test` subtest 3 skip
ok 11 - `test` subtest 3 skip # SKIP
ok 11 - `test` subtest 3 skip # SKIP 'only' option not set
---
duration_ms: *
...
Expand All @@ -206,8 +206,8 @@ ok 13 - describe only = true, with a mixture of subtests
---
duration_ms: *
...
# Subtest: async subtest should run
ok 2 - async subtest should run
# Subtest: async subtest should not run
ok 2 - async subtest should not run # SKIP 'only' option not set
---
duration_ms: *
...
Expand All @@ -225,9 +225,9 @@ ok 14 - describe only = true, with subtests
1..14
# tests 40
# suites 3
# pass 17
# pass 15
# fail 0
# cancelled 0
# skipped 23
# skipped 25
# todo 0
# duration_ms *

0 comments on commit 45c1ea8

Please sign in to comment.