From a547c423fb575360760500977a88c5a4c9b671ba Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 18 Mar 2024 14:11:33 -0400 Subject: [PATCH] test_runner: ignore todo flag when running suites This commit removes a check for the todo flag when determining if a suite should run. In general, the todo flag should have no impact on whether or not a test/suite runs. Instead, it should only impact how the result of the test/suite is handled. PR-URL: https://github.com/nodejs/node/pull/52117 Reviewed-By: Chemi Atlow Reviewed-By: Moshe Atlow --- lib/internal/test_runner/test.js | 2 +- .../test-runner/output/name_pattern.js | 10 +++++ .../test-runner/output/name_pattern.snapshot | 44 ++++++++++++++++--- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index ecedead32e3cc4..9edd0200a352b0 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -952,7 +952,7 @@ class Suite extends Test { constructor(options) { super(options); - if (testNamePatterns !== null && !options.skip && !options.todo) { + if (testNamePatterns !== null && !options.skip) { this.fn = options.fn || this.fn; this.skipped = false; } diff --git a/test/fixtures/test-runner/output/name_pattern.js b/test/fixtures/test-runner/output/name_pattern.js index 10e7619b9cfcb9..6994f7b54fc9a7 100644 --- a/test/fixtures/test-runner/output/name_pattern.js +++ b/test/fixtures/test-runner/output/name_pattern.js @@ -65,3 +65,13 @@ describe('no', function() { it('yes', () => {}); }); }); + +describe('no with todo', { todo: true }, () => { + it('no', () => {}); + it('yes', () => {}); + + describe('maybe', function() { + it('no', () => {}); + it('yes', () => {}); + }); +}); diff --git a/test/fixtures/test-runner/output/name_pattern.snapshot b/test/fixtures/test-runner/output/name_pattern.snapshot index bd53cc1fd2b89e..d4a0d459def1e6 100644 --- a/test/fixtures/test-runner/output/name_pattern.snapshot +++ b/test/fixtures/test-runner/output/name_pattern.snapshot @@ -171,12 +171,46 @@ ok 15 - no duration_ms: * type: 'suite' ... -1..15 -# tests 21 -# suites 10 -# pass 13 +# Subtest: no with todo + # Subtest: no + ok 1 - no # SKIP test name does not match pattern + --- + duration_ms: * + ... + # Subtest: yes + ok 2 - yes + --- + duration_ms: * + ... + # Subtest: maybe + # Subtest: no + ok 1 - no # SKIP test name does not match pattern + --- + duration_ms: * + ... + # Subtest: yes + ok 2 - yes + --- + duration_ms: * + ... + 1..2 + ok 3 - maybe + --- + duration_ms: * + type: 'suite' + ... + 1..3 +ok 16 - no with todo # TODO test name does not match pattern + --- + duration_ms: * + type: 'suite' + ... +1..16 +# tests 25 +# suites 12 +# pass 15 # fail 0 # cancelled 0 -# skipped 8 +# skipped 10 # todo 0 # duration_ms *