From 7d68a89b907c624e5faf28a924d11efc1c9bdf4c Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Thu, 1 Jun 2023 12:59:51 +0300 Subject: [PATCH] test_runner: apply `runOnly` on suites PR-URL: https://github.com/nodejs/node/pull/48279 Fixes: https://github.com/nodejs/node/issues/47937 Reviewed-By: Antoine du Hamel Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum --- lib/internal/test_runner/test.js | 2 ++ test/fixtures/test-runner/output/only_tests.js | 8 ++++---- .../test-runner/output/only_tests.snapshot | 16 ++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 310e794ab2945d..4dfbdcad0502ba 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -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]; diff --git a/test/fixtures/test-runner/output/only_tests.js b/test/fixtures/test-runner/output/only_tests.js index 9ed3154a5d6c67..5ac4a90c2cf264 100644 --- a/test/fixtures/test-runner/output/only_tests.js +++ b/test/fixtures/test-runner/output/only_tests.js @@ -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', () => { @@ -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 }, () => {}); }); diff --git a/test/fixtures/test-runner/output/only_tests.snapshot b/test/fixtures/test-runner/output/only_tests.snapshot index 4ee09070315b17..ded19f3bec4c6a 100644 --- a/test/fixtures/test-runner/output/only_tests.snapshot +++ b/test/fixtures/test-runner/output/only_tests.snapshot @@ -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: * ... @@ -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: * ... @@ -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: * ... @@ -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: * ... @@ -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 *