From 52d876674e9ac6703d99ceefeaa788171b50d6d8 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 30 Jul 2024 10:21:34 +0200 Subject: [PATCH 1/2] test_runner: fix erroneous diagnostic warning when only: false Co-author: rstagi --- lib/internal/test_runner/test.js | 6 +- .../test-runner/output/dot_reporter.snapshot | 3 +- .../output/junit_reporter.snapshot | 50 +- .../test-runner/output/lcov_reporter.snapshot | 495 ++++++++++-------- .../fixtures/test-runner/output/only_tests.js | 21 + .../test-runner/output/only_tests.snapshot | 45 +- test/fixtures/test-runner/output/output.js | 39 ++ .../test-runner/output/output.snapshot | 121 ++++- .../test-runner/output/output_cli.snapshot | 123 ++++- .../test-runner/output/spec_reporter.snapshot | 50 +- .../output/spec_reporter_cli.snapshot | 50 +- 11 files changed, 744 insertions(+), 259 deletions(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 1c461a07f16bfa..9c8cada98c810b 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -409,9 +409,9 @@ class Test extends AsyncResource { this.concurrency = parent.concurrency; this.nesting = nesting; - this.only = only ?? !parent.runOnlySubtests; + this.only = only ?? (parent.only && !parent.runOnlySubtests); this.reporter = parent.reporter; - this.runOnlySubtests = !this.only; + this.runOnlySubtests = false; this.childNumber = parent.subtests.length + 1; this.timeout = parent.timeout; this.entryFile = parent.entryFile; @@ -501,7 +501,7 @@ class Test extends AsyncResource { this.waitingOn = 0; this.finished = false; - if (!testOnlyFlag && (only || this.runOnlySubtests)) { + if (!testOnlyFlag && (only || this.parent?.runOnlySubtests)) { const warning = "'only' and 'runOnly' require the --test-only command-line option."; this.diagnostic(warning); diff --git a/test/fixtures/test-runner/output/dot_reporter.snapshot b/test/fixtures/test-runner/output/dot_reporter.snapshot index 5f2bf18e1d0137..828b40952eb3fe 100644 --- a/test/fixtures/test-runner/output/dot_reporter.snapshot +++ b/test/fixtures/test-runner/output/dot_reporter.snapshot @@ -1,7 +1,8 @@ ..XX...X..XXX.X..... XXX.....X..X...X.... .....X...XXX.XX..... -.XXXXXXX...XXXXX +.XXXXXXX...XXXX..... +..............X Failed tests: diff --git a/test/fixtures/test-runner/output/junit_reporter.snapshot b/test/fixtures/test-runner/output/junit_reporter.snapshot index d244e7dd594bb3..05c81312f70749 100644 --- a/test/fixtures/test-runner/output/junit_reporter.snapshot +++ b/test/fixtures/test-runner/output/junit_reporter.snapshot @@ -504,6 +504,38 @@ should loosely deep-equal } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error [ERR_TEST_FAILURE]: test could not be started because its parent finished @@ -514,16 +546,16 @@ Error [ERR_TEST_FAILURE]: test could not be started because its parent finished } - - + + - - - - - - - + + + + + + + diff --git a/test/fixtures/test-runner/output/lcov_reporter.snapshot b/test/fixtures/test-runner/output/lcov_reporter.snapshot index adc3abb005ea47..0d4d1c9f964484 100644 --- a/test/fixtures/test-runner/output/lcov_reporter.snapshot +++ b/test/fixtures/test-runner/output/lcov_reporter.snapshot @@ -1,106 +1,116 @@ TN: SF:test/fixtures/test-runner/output/output.js -FN:8,anonymous_0 -FN:12,anonymous_1 -FN:16,anonymous_2 -FN:21,anonymous_3 -FN:26,anonymous_4 -FN:30,anonymous_5 -FN:34,anonymous_6 -FN:38,anonymous_7 -FN:42,anonymous_8 -FN:46,anonymous_9 -FN:50,anonymous_10 -FN:54,anonymous_11 -FN:59,anonymous_12 -FN:64,anonymous_13 -FN:68,anonymous_14 -FN:72,anonymous_15 -FN:76,anonymous_16 -FN:80,anonymous_17 -FN:81,anonymous_18 -FN:86,anonymous_19 -FN:87,anonymous_20 -FN:92,anonymous_21 -FN:93,anonymous_22 -FN:94,anonymous_23 -FN:100,anonymous_24 -FN:101,anonymous_25 -FN:107,anonymous_26 -FN:111,anonymous_27 -FN:112,anonymous_28 -FN:113,anonymous_29 -FN:114,anonymous_30 -FN:122,anonymous_31 -FN:123,anonymous_32 -FN:130,anonymous_33 -FN:131,anonymous_34 -FN:132,anonymous_35 -FN:140,anonymous_36 -FN:141,anonymous_37 -FN:142,anonymous_38 -FN:150,anonymous_39 -FN:151,anonymous_40 -FN:159,anonymous_41 -FN:160,anonymous_42 -FN:161,anonymous_43 -FN:166,anonymous_44 -FN:167,anonymous_45 -FN:171,anonymous_46 -FN:172,anonymous_47 -FN:173,anonymous_48 -FN:179,anonymous_49 -FN:183,anonymous_50 -FN:187,anonymous_51 -FN:195,functionOnly -FN:198,anonymous_53 -FN:213,functionAndOptions -FN:215,anonymous_55 -FN:219,anonymous_56 -FN:220,anonymous_57 -FN:225,anonymous_58 -FN:229,anonymous_59 -FN:233,anonymous_60 -FN:238,anonymous_61 -FN:242,anonymous_62 -FN:246,anonymous_63 -FN:251,anonymous_64 -FN:256,anonymous_65 -FN:257,anonymous_66 -FN:263,anonymous_67 -FN:264,anonymous_68 -FN:269,anonymous_69 -FN:270,anonymous_70 -FN:277,anonymous_71 -FN:287,anonymous_72 -FN:289,obj -FN:298,anonymous_74 -FN:300,obj -FN:309,anonymous_76 -FN:310,anonymous_77 -FN:313,anonymous_78 -FN:318,anonymous_79 -FN:319,anonymous_80 -FN:320,anonymous_81 -FN:327,anonymous_82 -FN:328,anonymous_83 -FN:335,anonymous_84 -FN:336,anonymous_85 -FN:341,anonymous_86 -FN:345,anonymous_87 -FN:348,get then -FN:351,anonymous_89 -FN:356,anonymous_90 -FN:359,get then -FN:362,anonymous_92 -FN:367,anonymous_93 -FN:368,anonymous_94 -FN:369,anonymous_95 -FN:373,anonymous_96 -FN:374,anonymous_97 -FN:375,anonymous_98 -FN:381,anonymous_99 -FN:385,anonymous_100 +FN:9,anonymous_0 +FN:13,anonymous_1 +FN:17,anonymous_2 +FN:22,anonymous_3 +FN:27,anonymous_4 +FN:31,anonymous_5 +FN:35,anonymous_6 +FN:39,anonymous_7 +FN:43,anonymous_8 +FN:47,anonymous_9 +FN:51,anonymous_10 +FN:55,anonymous_11 +FN:60,anonymous_12 +FN:65,anonymous_13 +FN:69,anonymous_14 +FN:73,anonymous_15 +FN:77,anonymous_16 +FN:81,anonymous_17 +FN:82,anonymous_18 +FN:87,anonymous_19 +FN:88,anonymous_20 +FN:93,anonymous_21 +FN:94,anonymous_22 +FN:95,anonymous_23 +FN:101,anonymous_24 +FN:102,anonymous_25 +FN:108,anonymous_26 +FN:112,anonymous_27 +FN:113,anonymous_28 +FN:114,anonymous_29 +FN:115,anonymous_30 +FN:123,anonymous_31 +FN:124,anonymous_32 +FN:131,anonymous_33 +FN:132,anonymous_34 +FN:133,anonymous_35 +FN:141,anonymous_36 +FN:142,anonymous_37 +FN:143,anonymous_38 +FN:151,anonymous_39 +FN:152,anonymous_40 +FN:160,anonymous_41 +FN:161,anonymous_42 +FN:162,anonymous_43 +FN:167,anonymous_44 +FN:168,anonymous_45 +FN:172,anonymous_46 +FN:173,anonymous_47 +FN:174,anonymous_48 +FN:180,anonymous_49 +FN:184,anonymous_50 +FN:188,anonymous_51 +FN:196,functionOnly +FN:199,anonymous_53 +FN:214,functionAndOptions +FN:216,anonymous_55 +FN:220,anonymous_56 +FN:221,anonymous_57 +FN:226,anonymous_58 +FN:230,anonymous_59 +FN:234,anonymous_60 +FN:239,anonymous_61 +FN:243,anonymous_62 +FN:247,anonymous_63 +FN:252,anonymous_64 +FN:257,anonymous_65 +FN:258,anonymous_66 +FN:264,anonymous_67 +FN:265,anonymous_68 +FN:270,anonymous_69 +FN:271,anonymous_70 +FN:278,anonymous_71 +FN:288,anonymous_72 +FN:290,obj +FN:299,anonymous_74 +FN:301,obj +FN:310,anonymous_76 +FN:311,anonymous_77 +FN:314,anonymous_78 +FN:319,anonymous_79 +FN:320,anonymous_80 +FN:321,anonymous_81 +FN:328,anonymous_82 +FN:329,anonymous_83 +FN:336,anonymous_84 +FN:337,anonymous_85 +FN:342,anonymous_86 +FN:346,anonymous_87 +FN:349,get then +FN:352,anonymous_89 +FN:357,anonymous_90 +FN:360,get then +FN:363,anonymous_92 +FN:368,anonymous_93 +FN:369,anonymous_94 +FN:370,anonymous_95 +FN:374,anonymous_96 +FN:375,anonymous_97 +FN:376,anonymous_98 +FN:382,anonymous_99 +FN:386,anonymous_100 +FN:408,anonymous_101 +FN:412,anonymous_102 +FN:416,anonymous_103 +FN:420,anonymous_104 +FN:424,anonymous_105 +FN:428,anonymous_106 +FN:432,anonymous_107 +FN:436,anonymous_108 +FN:440,anonymous_109 +FN:441,anonymous_110 FNDA:1,anonymous_0 FNDA:1,anonymous_1 FNDA:1,anonymous_2 @@ -202,113 +212,133 @@ FNDA:1,anonymous_97 FNDA:1,anonymous_98 FNDA:1,anonymous_99 FNDA:1,anonymous_100 -FNF:101 -FNH:98 +FNDA:1,anonymous_101 +FNDA:1,anonymous_102 +FNDA:1,anonymous_103 +FNDA:1,anonymous_104 +FNDA:1,anonymous_105 +FNDA:1,anonymous_106 +FNDA:1,anonymous_107 +FNDA:1,anonymous_108 +FNDA:1,anonymous_109 +FNDA:1,anonymous_110 +FNF:111 +FNH:108 BRDA:1,0,0,1 -BRDA:8,1,0,1 -BRDA:12,2,0,1 -BRDA:16,3,0,1 -BRDA:21,4,0,1 -BRDA:26,5,0,1 -BRDA:30,6,0,1 -BRDA:34,7,0,1 -BRDA:38,8,0,1 -BRDA:42,9,0,1 -BRDA:46,10,0,1 -BRDA:50,11,0,1 -BRDA:54,12,0,1 -BRDA:59,13,0,1 -BRDA:64,14,0,1 -BRDA:68,15,0,1 -BRDA:72,16,0,1 -BRDA:76,17,0,1 -BRDA:80,18,0,1 -BRDA:81,19,0,1 -BRDA:86,20,0,1 -BRDA:87,21,0,1 -BRDA:92,22,0,1 -BRDA:93,23,0,1 -BRDA:94,24,0,1 -BRDA:100,25,0,1 -BRDA:101,26,0,1 -BRDA:107,27,0,1 -BRDA:111,28,0,1 -BRDA:112,29,0,1 -BRDA:113,30,0,1 -BRDA:114,31,0,1 -BRDA:122,32,0,1 -BRDA:123,33,0,1 -BRDA:130,34,0,1 -BRDA:131,35,0,1 -BRDA:132,36,0,1 -BRDA:140,37,0,1 -BRDA:141,38,0,1 -BRDA:142,39,0,1 -BRDA:150,40,0,1 -BRDA:151,41,0,1 -BRDA:159,42,0,1 -BRDA:160,43,0,1 -BRDA:161,44,0,1 -BRDA:166,45,0,1 -BRDA:167,46,0,1 -BRDA:171,47,0,1 -BRDA:172,48,0,1 -BRDA:173,49,0,1 -BRDA:187,50,0,1 -BRDA:195,51,0,1 -BRDA:198,52,0,1 -BRDA:215,53,0,1 -BRDA:219,54,0,1 -BRDA:220,55,0,1 -BRDA:225,56,0,1 -BRDA:229,57,0,1 -BRDA:233,58,0,1 -BRDA:238,59,0,1 -BRDA:242,60,0,1 -BRDA:246,61,0,1 -BRDA:251,62,0,1 -BRDA:256,63,0,1 -BRDA:257,64,0,1 -BRDA:263,65,0,1 -BRDA:264,66,0,1 -BRDA:269,67,0,1 -BRDA:270,68,0,1 -BRDA:277,69,0,1 -BRDA:287,70,0,1 -BRDA:289,71,0,1 -BRDA:298,72,0,1 -BRDA:300,73,0,1 -BRDA:309,74,0,1 -BRDA:310,75,0,1 -BRDA:313,76,0,1 -BRDA:318,77,0,1 -BRDA:319,78,0,1 -BRDA:320,79,0,1 -BRDA:327,80,0,1 -BRDA:328,81,0,1 -BRDA:335,82,0,1 -BRDA:336,83,0,1 -BRDA:341,84,0,1 -BRDA:345,85,0,1 -BRDA:348,86,0,1 -BRDA:349,87,0,0 -BRDA:351,88,0,1 -BRDA:356,89,0,1 -BRDA:359,90,0,1 -BRDA:360,91,0,0 -BRDA:362,92,0,1 -BRDA:367,93,0,1 -BRDA:370,94,0,0 -BRDA:368,95,0,1 -BRDA:369,96,0,1 -BRDA:373,97,0,1 -BRDA:376,98,0,0 -BRDA:374,99,0,1 -BRDA:375,100,0,1 -BRDA:381,101,0,1 -BRDA:385,102,0,1 -BRF:103 -BRH:99 +BRDA:9,1,0,1 +BRDA:13,2,0,1 +BRDA:17,3,0,1 +BRDA:22,4,0,1 +BRDA:27,5,0,1 +BRDA:31,6,0,1 +BRDA:35,7,0,1 +BRDA:39,8,0,1 +BRDA:43,9,0,1 +BRDA:47,10,0,1 +BRDA:51,11,0,1 +BRDA:55,12,0,1 +BRDA:60,13,0,1 +BRDA:65,14,0,1 +BRDA:69,15,0,1 +BRDA:73,16,0,1 +BRDA:77,17,0,1 +BRDA:81,18,0,1 +BRDA:82,19,0,1 +BRDA:87,20,0,1 +BRDA:88,21,0,1 +BRDA:93,22,0,1 +BRDA:94,23,0,1 +BRDA:95,24,0,1 +BRDA:101,25,0,1 +BRDA:102,26,0,1 +BRDA:108,27,0,1 +BRDA:112,28,0,1 +BRDA:113,29,0,1 +BRDA:114,30,0,1 +BRDA:115,31,0,1 +BRDA:123,32,0,1 +BRDA:124,33,0,1 +BRDA:131,34,0,1 +BRDA:132,35,0,1 +BRDA:133,36,0,1 +BRDA:141,37,0,1 +BRDA:142,38,0,1 +BRDA:143,39,0,1 +BRDA:151,40,0,1 +BRDA:152,41,0,1 +BRDA:160,42,0,1 +BRDA:161,43,0,1 +BRDA:162,44,0,1 +BRDA:167,45,0,1 +BRDA:168,46,0,1 +BRDA:172,47,0,1 +BRDA:173,48,0,1 +BRDA:174,49,0,1 +BRDA:188,50,0,1 +BRDA:196,51,0,1 +BRDA:199,52,0,1 +BRDA:216,53,0,1 +BRDA:220,54,0,1 +BRDA:221,55,0,1 +BRDA:226,56,0,1 +BRDA:230,57,0,1 +BRDA:234,58,0,1 +BRDA:239,59,0,1 +BRDA:243,60,0,1 +BRDA:247,61,0,1 +BRDA:252,62,0,1 +BRDA:257,63,0,1 +BRDA:258,64,0,1 +BRDA:264,65,0,1 +BRDA:265,66,0,1 +BRDA:270,67,0,1 +BRDA:271,68,0,1 +BRDA:278,69,0,1 +BRDA:288,70,0,1 +BRDA:290,71,0,1 +BRDA:299,72,0,1 +BRDA:301,73,0,1 +BRDA:310,74,0,1 +BRDA:311,75,0,1 +BRDA:314,76,0,1 +BRDA:319,77,0,1 +BRDA:320,78,0,1 +BRDA:321,79,0,1 +BRDA:328,80,0,1 +BRDA:329,81,0,1 +BRDA:336,82,0,1 +BRDA:337,83,0,1 +BRDA:342,84,0,1 +BRDA:346,85,0,1 +BRDA:349,86,0,1 +BRDA:350,87,0,0 +BRDA:352,88,0,1 +BRDA:357,89,0,1 +BRDA:360,90,0,1 +BRDA:361,91,0,0 +BRDA:363,92,0,1 +BRDA:368,93,0,1 +BRDA:371,94,0,0 +BRDA:369,95,0,1 +BRDA:370,96,0,1 +BRDA:374,97,0,1 +BRDA:377,98,0,0 +BRDA:375,99,0,1 +BRDA:376,100,0,1 +BRDA:382,101,0,1 +BRDA:386,102,0,1 +BRDA:408,103,0,1 +BRDA:412,104,0,1 +BRDA:416,105,0,1 +BRDA:420,106,0,1 +BRDA:424,107,0,1 +BRDA:428,108,0,1 +BRDA:432,109,0,1 +BRDA:436,110,0,1 +BRDA:440,111,0,1 +BRDA:441,112,0,1 +BRF:113 +BRH:109 DA:1,1 DA:2,1 DA:3,1 @@ -488,12 +518,12 @@ DA:176,1 DA:177,1 DA:178,1 DA:179,1 -DA:180,0 -DA:181,1 +DA:180,1 +DA:181,0 DA:182,1 DA:183,1 -DA:184,0 -DA:185,1 +DA:184,1 +DA:185,0 DA:186,1 DA:187,1 DA:188,1 @@ -714,6 +744,45 @@ DA:402,1 DA:403,1 DA:404,1 DA:405,1 -LH:403 -LF:405 +DA:406,1 +DA:407,1 +DA:408,1 +DA:409,1 +DA:410,1 +DA:411,1 +DA:412,1 +DA:413,1 +DA:414,1 +DA:415,1 +DA:416,1 +DA:417,1 +DA:418,1 +DA:419,1 +DA:420,1 +DA:421,1 +DA:422,1 +DA:423,1 +DA:424,1 +DA:425,1 +DA:426,1 +DA:427,1 +DA:428,1 +DA:429,1 +DA:430,1 +DA:431,1 +DA:432,1 +DA:433,1 +DA:434,1 +DA:435,1 +DA:436,1 +DA:437,1 +DA:438,1 +DA:439,1 +DA:440,1 +DA:441,1 +DA:442,1 +DA:443,1 +DA:444,1 +LH:442 +LF:444 end_of_record diff --git a/test/fixtures/test-runner/output/only_tests.js b/test/fixtures/test-runner/output/only_tests.js index e2f6975e5b8268..616a3351886362 100644 --- a/test/fixtures/test-runner/output/only_tests.js +++ b/test/fixtures/test-runner/output/only_tests.js @@ -119,3 +119,24 @@ describe('describe only = false, with nested only subtests', { only: false }, co test.only('nested test should run', common.mustNotCall()); })); })); + +test('nested tests with run only',{only: true}, common.mustCall(async (t) => { + // Within this test, all subtests are run by default. + await t.test('running subtest - 1'); + + // The test context can be updated to run subtests with the 'only' option. + await t.runOnly(true); + await t.test('this subtest is now skipped - 2', common.mustNotCall()); + await t.test('this subtest is run - 3', { only: true }, common.mustCall(async (t) => { + await t.test('this subtest is run - 4', common.mustCall()); + await t.test('this subtest is run - 5', { only: true }, common.mustCall()); + })); + + // Switch the context back to execute all tests. + await t.runOnly(false); + await t.test('this subtest is now run - 6'); + + // Explicitly do not run these tests. + await t.test('skipped subtest - 7', { only: false }, common.mustNotCall()); + await t.test('skipped subtest - 8', { skip: true }, common.mustNotCall()); +})) diff --git a/test/fixtures/test-runner/output/only_tests.snapshot b/test/fixtures/test-runner/output/only_tests.snapshot index aa71e4529f4b1c..25e2e9b65cdca2 100644 --- a/test/fixtures/test-runner/output/only_tests.snapshot +++ b/test/fixtures/test-runner/output/only_tests.snapshot @@ -155,12 +155,49 @@ ok 8 - describe only = true, with nested subtests duration_ms: * type: 'suite' ... -1..8 -# tests 21 +# Subtest: nested tests with run only + # Subtest: running subtest - 1 + ok 1 - running subtest - 1 + --- + duration_ms: * + ... + # Subtest: this subtest is run - 3 + # Subtest: this subtest is run - 4 + ok 1 - this subtest is run - 4 + --- + duration_ms: * + ... + # Subtest: this subtest is run - 5 + ok 2 - this subtest is run - 5 + --- + duration_ms: * + ... + 1..2 + ok 2 - this subtest is run - 3 + --- + duration_ms: * + ... + # Subtest: this subtest is now run - 6 + ok 3 - this subtest is now run - 6 + --- + duration_ms: * + ... + # Subtest: skipped subtest - 8 + ok 4 - skipped subtest - 8 # SKIP + --- + duration_ms: * + ... + 1..4 +ok 9 - nested tests with run only + --- + duration_ms: * + ... +1..9 +# tests 28 # suites 7 -# pass 18 +# pass 24 # fail 0 # cancelled 0 -# skipped 3 +# skipped 4 # todo 0 # duration_ms * diff --git a/test/fixtures/test-runner/output/output.js b/test/fixtures/test-runner/output/output.js index ff1b2958774052..83a0958761b456 100644 --- a/test/fixtures/test-runner/output/output.js +++ b/test/fixtures/test-runner/output/output.js @@ -3,6 +3,7 @@ require('../../../common'); const assert = require('node:assert'); const test = require('node:test'); +const { describe, it } = require('node:test'); const util = require('util'); test('sync pass todo', (t) => { @@ -403,3 +404,41 @@ test('assertion errors display actual and expected properly', async () => { throw err; } }); + +describe('should NOT print --test-only diagnostic warning - describe-only-false', {only: false}, () => { + it('only false in describe'); +}); + +describe('should NOT print --test-only diagnostic warning - it-only-false', () => { + it('only false in the subtest', {only: false}); +}); + +describe('should NOT print --test-only diagnostic warning - no-only', () => { + it('no only'); +}); + +test('should NOT print --test-only diagnostic warning - test-only-false', {only: false}, async (t) => { + await t.test('only false in parent test'); +}); + +test('should NOT print --test-only diagnostic warning - t.test-only-false', async (t) => { + await t.test('only false in subtest', {only: false}); +}); + +test('should NOT print --test-only diagnostic warning - no-only', async (t) => { + await t.test('no only'); +}); + +test('should print --test-only diagnostic warning - test-only-true', {only: true}, async (t) => { + await t.test('only true in parent test'); +}) + +test('should print --test-only diagnostic warning - t.test-only-true', async (t) => { + await t.test('only true in subtest', {only: true}); +}); + +test('should print --test-only diagnostic warning - 2 levels of only', async (t) => { + await t.test('only true in parent test', {only: false}, async (t) => { + await t.test('only true in subtest', {only: true}); + }); +}) diff --git a/test/fixtures/test-runner/output/output.snapshot b/test/fixtures/test-runner/output/output.snapshot index 0acb6573bc6710..0df6bcbece15fc 100644 --- a/test/fixtures/test-runner/output/output.snapshot +++ b/test/fixtures/test-runner/output/output.snapshot @@ -699,8 +699,119 @@ not ok 61 - assertion errors display actual and expected properly stack: |- * ... +# Subtest: should NOT print --test-only diagnostic warning - describe-only-false + # Subtest: only false in describe + ok 1 - only false in describe + --- + duration_ms: * + ... + 1..1 +ok 62 - should NOT print --test-only diagnostic warning - describe-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - it-only-false + # Subtest: only false in the subtest + ok 1 - only false in the subtest + --- + duration_ms: * + ... + 1..1 +ok 63 - should NOT print --test-only diagnostic warning - it-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 64 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - test-only-false + # Subtest: only false in parent test + ok 1 - only false in parent test + --- + duration_ms: * + ... + 1..1 +ok 65 - should NOT print --test-only diagnostic warning - test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - t.test-only-false + # Subtest: only false in subtest + ok 1 - only false in subtest + --- + duration_ms: * + ... + 1..1 +ok 66 - should NOT print --test-only diagnostic warning - t.test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 67 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - test-only-true + # Subtest: only true in parent test + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 68 - should print --test-only diagnostic warning - test-only-true + --- + duration_ms: * + ... +# 'only' and 'runOnly' require the --test-only command-line option. +# Subtest: should print --test-only diagnostic warning - t.test-only-true + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 +ok 69 - should print --test-only diagnostic warning - t.test-only-true + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - 2 levels of only + # Subtest: only true in parent test + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 70 - should print --test-only diagnostic warning - 2 levels of only + --- + duration_ms: * + ... # Subtest: invalid subtest fail -not ok 62 - invalid subtest fail +not ok 71 - invalid subtest fail --- duration_ms: * location: '/test/fixtures/test-runner/output/output.js:(LINE):7' @@ -710,7 +821,7 @@ not ok 62 - invalid subtest fail stack: |- * ... -1..62 +1..71 # Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. @@ -718,9 +829,9 @@ not ok 62 - invalid subtest fail # Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. # Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. -# tests 76 -# suites 0 -# pass 35 +# tests 92 +# suites 3 +# pass 51 # fail 25 # cancelled 3 # skipped 9 diff --git a/test/fixtures/test-runner/output/output_cli.snapshot b/test/fixtures/test-runner/output/output_cli.snapshot index d04dc0a0a905ad..046ba16c5781d6 100644 --- a/test/fixtures/test-runner/output/output_cli.snapshot +++ b/test/fixtures/test-runner/output/output_cli.snapshot @@ -699,8 +699,119 @@ not ok 61 - assertion errors display actual and expected properly stack: |- * ... +# Subtest: should NOT print --test-only diagnostic warning - describe-only-false + # Subtest: only false in describe + ok 1 - only false in describe + --- + duration_ms: * + ... + 1..1 +ok 62 - should NOT print --test-only diagnostic warning - describe-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - it-only-false + # Subtest: only false in the subtest + ok 1 - only false in the subtest + --- + duration_ms: * + ... + 1..1 +ok 63 - should NOT print --test-only diagnostic warning - it-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 64 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - test-only-false + # Subtest: only false in parent test + ok 1 - only false in parent test + --- + duration_ms: * + ... + 1..1 +ok 65 - should NOT print --test-only diagnostic warning - test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - t.test-only-false + # Subtest: only false in subtest + ok 1 - only false in subtest + --- + duration_ms: * + ... + 1..1 +ok 66 - should NOT print --test-only diagnostic warning - t.test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 67 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - test-only-true + # Subtest: only true in parent test + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 68 - should print --test-only diagnostic warning - test-only-true + --- + duration_ms: * + ... +# 'only' and 'runOnly' require the --test-only command-line option. +# Subtest: should print --test-only diagnostic warning - t.test-only-true + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 +ok 69 - should print --test-only diagnostic warning - t.test-only-true + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - 2 levels of only + # Subtest: only true in parent test + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 70 - should print --test-only diagnostic warning - 2 levels of only + --- + duration_ms: * + ... # Subtest: invalid subtest fail -not ok 62 - invalid subtest fail +not ok 71 - invalid subtest fail --- duration_ms: * location: '/test/fixtures/test-runner/output/output.js:(LINE):7' @@ -718,14 +829,14 @@ not ok 62 - invalid subtest fail # Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. # Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. # Subtest: last test -ok 63 - last test +ok 72 - last test --- duration_ms: * ... -1..63 -# tests 77 -# suites 0 -# pass 36 +1..72 +# tests 93 +# suites 3 +# pass 52 # fail 25 # cancelled 3 # skipped 9 diff --git a/test/fixtures/test-runner/output/spec_reporter.snapshot b/test/fixtures/test-runner/output/spec_reporter.snapshot index f37d7f35b8a7d6..53f526b9320e43 100644 --- a/test/fixtures/test-runner/output/spec_reporter.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter.snapshot @@ -294,19 +294,51 @@ operator: 'deepEqual' } + should NOT print --test-only diagnostic warning - describe-only-false + only false in describe (*ms) + should NOT print --test-only diagnostic warning - describe-only-false (*ms) + should NOT print --test-only diagnostic warning - it-only-false + only false in the subtest (*ms) + should NOT print --test-only diagnostic warning - it-only-false (*ms) + should NOT print --test-only diagnostic warning - no-only + no only (*ms) + should NOT print --test-only diagnostic warning - no-only (*ms) + should NOT print --test-only diagnostic warning - test-only-false + only false in parent test (*ms) + should NOT print --test-only diagnostic warning - test-only-false (*ms) + should NOT print --test-only diagnostic warning - t.test-only-false + only false in subtest (*ms) + should NOT print --test-only diagnostic warning - t.test-only-false (*ms) + should NOT print --test-only diagnostic warning - no-only + no only (*ms) + should NOT print --test-only diagnostic warning - no-only (*ms) + should print --test-only diagnostic warning - test-only-true + only true in parent test (*ms) + should print --test-only diagnostic warning - test-only-true (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + should print --test-only diagnostic warning - t.test-only-true + only true in subtest (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + should print --test-only diagnostic warning - t.test-only-true (*ms) + should print --test-only diagnostic warning - 2 levels of only + only true in parent test + only true in subtest (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + only true in parent test (*ms) + should print --test-only diagnostic warning - 2 levels of only (*ms) invalid subtest fail (*ms) 'test could not be started because its parent finished' - Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:73:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:77:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. - Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:80:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:86:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:251:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:269:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. - tests 76 - suites 0 - pass 35 + Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:81:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:87:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:252:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:270:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. + tests 92 + suites 3 + pass 51 fail 25 cancelled 3 skipped 9 diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot index d8648bfe03a8be..675a1dc8d7434a 100644 --- a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot @@ -294,19 +294,51 @@ operator: 'deepEqual' } + should NOT print --test-only diagnostic warning - describe-only-false + only false in describe (*ms) + should NOT print --test-only diagnostic warning - describe-only-false (*ms) + should NOT print --test-only diagnostic warning - it-only-false + only false in the subtest (*ms) + should NOT print --test-only diagnostic warning - it-only-false (*ms) + should NOT print --test-only diagnostic warning - no-only + no only (*ms) + should NOT print --test-only diagnostic warning - no-only (*ms) + should NOT print --test-only diagnostic warning - test-only-false + only false in parent test (*ms) + should NOT print --test-only diagnostic warning - test-only-false (*ms) + should NOT print --test-only diagnostic warning - t.test-only-false + only false in subtest (*ms) + should NOT print --test-only diagnostic warning - t.test-only-false (*ms) + should NOT print --test-only diagnostic warning - no-only + no only (*ms) + should NOT print --test-only diagnostic warning - no-only (*ms) + should print --test-only diagnostic warning - test-only-true + only true in parent test (*ms) + should print --test-only diagnostic warning - test-only-true (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + should print --test-only diagnostic warning - t.test-only-true + only true in subtest (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + should print --test-only diagnostic warning - t.test-only-true (*ms) + should print --test-only diagnostic warning - 2 levels of only + only true in parent test + only true in subtest (*ms) + 'only' and 'runOnly' require the --test-only command-line option. + only true in parent test (*ms) + should print --test-only diagnostic warning - 2 levels of only (*ms) invalid subtest fail (*ms) 'test could not be started because its parent finished' - Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:73:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:77:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. - Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:80:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:86:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:251:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:269:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. - tests 76 - suites 0 - pass 35 + Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:81:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:87:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:252:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:270:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. + tests 92 + suites 3 + pass 51 fail 25 cancelled 3 skipped 9 From bbe850404425ac55c1fb3fdef6e01f1bd6a91404 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Wed, 31 Jul 2024 08:50:07 +0200 Subject: [PATCH 2/2] test_runner: move --test-only diagnostic warning tests to separate file --- .../test-runner/output/dot_reporter.snapshot | 3 +- .../output/junit_reporter.snapshot | 50 +- .../test-runner/output/lcov_reporter.snapshot | 495 ++++++++---------- test/fixtures/test-runner/output/output.js | 39 -- .../test-runner/output/output.snapshot | 121 +---- .../test-runner/output/output_cli.snapshot | 123 +---- .../test-runner/output/spec_reporter.snapshot | 50 +- .../output/spec_reporter_cli.snapshot | 50 +- ...agnostic-warning-without-test-only-flag.js | 40 ++ ...ic-warning-without-test-only-flag.snapshot | 121 +++++ test/parallel/test-runner-output.mjs | 1 + 11 files changed, 414 insertions(+), 679 deletions(-) create mode 100644 test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.js create mode 100644 test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.snapshot diff --git a/test/fixtures/test-runner/output/dot_reporter.snapshot b/test/fixtures/test-runner/output/dot_reporter.snapshot index 828b40952eb3fe..5f2bf18e1d0137 100644 --- a/test/fixtures/test-runner/output/dot_reporter.snapshot +++ b/test/fixtures/test-runner/output/dot_reporter.snapshot @@ -1,8 +1,7 @@ ..XX...X..XXX.X..... XXX.....X..X...X.... .....X...XXX.XX..... -.XXXXXXX...XXXX..... -..............X +.XXXXXXX...XXXXX Failed tests: diff --git a/test/fixtures/test-runner/output/junit_reporter.snapshot b/test/fixtures/test-runner/output/junit_reporter.snapshot index 05c81312f70749..d244e7dd594bb3 100644 --- a/test/fixtures/test-runner/output/junit_reporter.snapshot +++ b/test/fixtures/test-runner/output/junit_reporter.snapshot @@ -504,38 +504,6 @@ should loosely deep-equal } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Error [ERR_TEST_FAILURE]: test could not be started because its parent finished @@ -546,16 +514,16 @@ Error [ERR_TEST_FAILURE]: test could not be started because its parent finished } - - + + - - - - - - - + + + + + + + diff --git a/test/fixtures/test-runner/output/lcov_reporter.snapshot b/test/fixtures/test-runner/output/lcov_reporter.snapshot index 0d4d1c9f964484..adc3abb005ea47 100644 --- a/test/fixtures/test-runner/output/lcov_reporter.snapshot +++ b/test/fixtures/test-runner/output/lcov_reporter.snapshot @@ -1,116 +1,106 @@ TN: SF:test/fixtures/test-runner/output/output.js -FN:9,anonymous_0 -FN:13,anonymous_1 -FN:17,anonymous_2 -FN:22,anonymous_3 -FN:27,anonymous_4 -FN:31,anonymous_5 -FN:35,anonymous_6 -FN:39,anonymous_7 -FN:43,anonymous_8 -FN:47,anonymous_9 -FN:51,anonymous_10 -FN:55,anonymous_11 -FN:60,anonymous_12 -FN:65,anonymous_13 -FN:69,anonymous_14 -FN:73,anonymous_15 -FN:77,anonymous_16 -FN:81,anonymous_17 -FN:82,anonymous_18 -FN:87,anonymous_19 -FN:88,anonymous_20 -FN:93,anonymous_21 -FN:94,anonymous_22 -FN:95,anonymous_23 -FN:101,anonymous_24 -FN:102,anonymous_25 -FN:108,anonymous_26 -FN:112,anonymous_27 -FN:113,anonymous_28 -FN:114,anonymous_29 -FN:115,anonymous_30 -FN:123,anonymous_31 -FN:124,anonymous_32 -FN:131,anonymous_33 -FN:132,anonymous_34 -FN:133,anonymous_35 -FN:141,anonymous_36 -FN:142,anonymous_37 -FN:143,anonymous_38 -FN:151,anonymous_39 -FN:152,anonymous_40 -FN:160,anonymous_41 -FN:161,anonymous_42 -FN:162,anonymous_43 -FN:167,anonymous_44 -FN:168,anonymous_45 -FN:172,anonymous_46 -FN:173,anonymous_47 -FN:174,anonymous_48 -FN:180,anonymous_49 -FN:184,anonymous_50 -FN:188,anonymous_51 -FN:196,functionOnly -FN:199,anonymous_53 -FN:214,functionAndOptions -FN:216,anonymous_55 -FN:220,anonymous_56 -FN:221,anonymous_57 -FN:226,anonymous_58 -FN:230,anonymous_59 -FN:234,anonymous_60 -FN:239,anonymous_61 -FN:243,anonymous_62 -FN:247,anonymous_63 -FN:252,anonymous_64 -FN:257,anonymous_65 -FN:258,anonymous_66 -FN:264,anonymous_67 -FN:265,anonymous_68 -FN:270,anonymous_69 -FN:271,anonymous_70 -FN:278,anonymous_71 -FN:288,anonymous_72 -FN:290,obj -FN:299,anonymous_74 -FN:301,obj -FN:310,anonymous_76 -FN:311,anonymous_77 -FN:314,anonymous_78 -FN:319,anonymous_79 -FN:320,anonymous_80 -FN:321,anonymous_81 -FN:328,anonymous_82 -FN:329,anonymous_83 -FN:336,anonymous_84 -FN:337,anonymous_85 -FN:342,anonymous_86 -FN:346,anonymous_87 -FN:349,get then -FN:352,anonymous_89 -FN:357,anonymous_90 -FN:360,get then -FN:363,anonymous_92 -FN:368,anonymous_93 -FN:369,anonymous_94 -FN:370,anonymous_95 -FN:374,anonymous_96 -FN:375,anonymous_97 -FN:376,anonymous_98 -FN:382,anonymous_99 -FN:386,anonymous_100 -FN:408,anonymous_101 -FN:412,anonymous_102 -FN:416,anonymous_103 -FN:420,anonymous_104 -FN:424,anonymous_105 -FN:428,anonymous_106 -FN:432,anonymous_107 -FN:436,anonymous_108 -FN:440,anonymous_109 -FN:441,anonymous_110 +FN:8,anonymous_0 +FN:12,anonymous_1 +FN:16,anonymous_2 +FN:21,anonymous_3 +FN:26,anonymous_4 +FN:30,anonymous_5 +FN:34,anonymous_6 +FN:38,anonymous_7 +FN:42,anonymous_8 +FN:46,anonymous_9 +FN:50,anonymous_10 +FN:54,anonymous_11 +FN:59,anonymous_12 +FN:64,anonymous_13 +FN:68,anonymous_14 +FN:72,anonymous_15 +FN:76,anonymous_16 +FN:80,anonymous_17 +FN:81,anonymous_18 +FN:86,anonymous_19 +FN:87,anonymous_20 +FN:92,anonymous_21 +FN:93,anonymous_22 +FN:94,anonymous_23 +FN:100,anonymous_24 +FN:101,anonymous_25 +FN:107,anonymous_26 +FN:111,anonymous_27 +FN:112,anonymous_28 +FN:113,anonymous_29 +FN:114,anonymous_30 +FN:122,anonymous_31 +FN:123,anonymous_32 +FN:130,anonymous_33 +FN:131,anonymous_34 +FN:132,anonymous_35 +FN:140,anonymous_36 +FN:141,anonymous_37 +FN:142,anonymous_38 +FN:150,anonymous_39 +FN:151,anonymous_40 +FN:159,anonymous_41 +FN:160,anonymous_42 +FN:161,anonymous_43 +FN:166,anonymous_44 +FN:167,anonymous_45 +FN:171,anonymous_46 +FN:172,anonymous_47 +FN:173,anonymous_48 +FN:179,anonymous_49 +FN:183,anonymous_50 +FN:187,anonymous_51 +FN:195,functionOnly +FN:198,anonymous_53 +FN:213,functionAndOptions +FN:215,anonymous_55 +FN:219,anonymous_56 +FN:220,anonymous_57 +FN:225,anonymous_58 +FN:229,anonymous_59 +FN:233,anonymous_60 +FN:238,anonymous_61 +FN:242,anonymous_62 +FN:246,anonymous_63 +FN:251,anonymous_64 +FN:256,anonymous_65 +FN:257,anonymous_66 +FN:263,anonymous_67 +FN:264,anonymous_68 +FN:269,anonymous_69 +FN:270,anonymous_70 +FN:277,anonymous_71 +FN:287,anonymous_72 +FN:289,obj +FN:298,anonymous_74 +FN:300,obj +FN:309,anonymous_76 +FN:310,anonymous_77 +FN:313,anonymous_78 +FN:318,anonymous_79 +FN:319,anonymous_80 +FN:320,anonymous_81 +FN:327,anonymous_82 +FN:328,anonymous_83 +FN:335,anonymous_84 +FN:336,anonymous_85 +FN:341,anonymous_86 +FN:345,anonymous_87 +FN:348,get then +FN:351,anonymous_89 +FN:356,anonymous_90 +FN:359,get then +FN:362,anonymous_92 +FN:367,anonymous_93 +FN:368,anonymous_94 +FN:369,anonymous_95 +FN:373,anonymous_96 +FN:374,anonymous_97 +FN:375,anonymous_98 +FN:381,anonymous_99 +FN:385,anonymous_100 FNDA:1,anonymous_0 FNDA:1,anonymous_1 FNDA:1,anonymous_2 @@ -212,133 +202,113 @@ FNDA:1,anonymous_97 FNDA:1,anonymous_98 FNDA:1,anonymous_99 FNDA:1,anonymous_100 -FNDA:1,anonymous_101 -FNDA:1,anonymous_102 -FNDA:1,anonymous_103 -FNDA:1,anonymous_104 -FNDA:1,anonymous_105 -FNDA:1,anonymous_106 -FNDA:1,anonymous_107 -FNDA:1,anonymous_108 -FNDA:1,anonymous_109 -FNDA:1,anonymous_110 -FNF:111 -FNH:108 +FNF:101 +FNH:98 BRDA:1,0,0,1 -BRDA:9,1,0,1 -BRDA:13,2,0,1 -BRDA:17,3,0,1 -BRDA:22,4,0,1 -BRDA:27,5,0,1 -BRDA:31,6,0,1 -BRDA:35,7,0,1 -BRDA:39,8,0,1 -BRDA:43,9,0,1 -BRDA:47,10,0,1 -BRDA:51,11,0,1 -BRDA:55,12,0,1 -BRDA:60,13,0,1 -BRDA:65,14,0,1 -BRDA:69,15,0,1 -BRDA:73,16,0,1 -BRDA:77,17,0,1 -BRDA:81,18,0,1 -BRDA:82,19,0,1 -BRDA:87,20,0,1 -BRDA:88,21,0,1 -BRDA:93,22,0,1 -BRDA:94,23,0,1 -BRDA:95,24,0,1 -BRDA:101,25,0,1 -BRDA:102,26,0,1 -BRDA:108,27,0,1 -BRDA:112,28,0,1 -BRDA:113,29,0,1 -BRDA:114,30,0,1 -BRDA:115,31,0,1 -BRDA:123,32,0,1 -BRDA:124,33,0,1 -BRDA:131,34,0,1 -BRDA:132,35,0,1 -BRDA:133,36,0,1 -BRDA:141,37,0,1 -BRDA:142,38,0,1 -BRDA:143,39,0,1 -BRDA:151,40,0,1 -BRDA:152,41,0,1 -BRDA:160,42,0,1 -BRDA:161,43,0,1 -BRDA:162,44,0,1 -BRDA:167,45,0,1 -BRDA:168,46,0,1 -BRDA:172,47,0,1 -BRDA:173,48,0,1 -BRDA:174,49,0,1 -BRDA:188,50,0,1 -BRDA:196,51,0,1 -BRDA:199,52,0,1 -BRDA:216,53,0,1 -BRDA:220,54,0,1 -BRDA:221,55,0,1 -BRDA:226,56,0,1 -BRDA:230,57,0,1 -BRDA:234,58,0,1 -BRDA:239,59,0,1 -BRDA:243,60,0,1 -BRDA:247,61,0,1 -BRDA:252,62,0,1 -BRDA:257,63,0,1 -BRDA:258,64,0,1 -BRDA:264,65,0,1 -BRDA:265,66,0,1 -BRDA:270,67,0,1 -BRDA:271,68,0,1 -BRDA:278,69,0,1 -BRDA:288,70,0,1 -BRDA:290,71,0,1 -BRDA:299,72,0,1 -BRDA:301,73,0,1 -BRDA:310,74,0,1 -BRDA:311,75,0,1 -BRDA:314,76,0,1 -BRDA:319,77,0,1 -BRDA:320,78,0,1 -BRDA:321,79,0,1 -BRDA:328,80,0,1 -BRDA:329,81,0,1 -BRDA:336,82,0,1 -BRDA:337,83,0,1 -BRDA:342,84,0,1 -BRDA:346,85,0,1 -BRDA:349,86,0,1 -BRDA:350,87,0,0 -BRDA:352,88,0,1 -BRDA:357,89,0,1 -BRDA:360,90,0,1 -BRDA:361,91,0,0 -BRDA:363,92,0,1 -BRDA:368,93,0,1 -BRDA:371,94,0,0 -BRDA:369,95,0,1 -BRDA:370,96,0,1 -BRDA:374,97,0,1 -BRDA:377,98,0,0 -BRDA:375,99,0,1 -BRDA:376,100,0,1 -BRDA:382,101,0,1 -BRDA:386,102,0,1 -BRDA:408,103,0,1 -BRDA:412,104,0,1 -BRDA:416,105,0,1 -BRDA:420,106,0,1 -BRDA:424,107,0,1 -BRDA:428,108,0,1 -BRDA:432,109,0,1 -BRDA:436,110,0,1 -BRDA:440,111,0,1 -BRDA:441,112,0,1 -BRF:113 -BRH:109 +BRDA:8,1,0,1 +BRDA:12,2,0,1 +BRDA:16,3,0,1 +BRDA:21,4,0,1 +BRDA:26,5,0,1 +BRDA:30,6,0,1 +BRDA:34,7,0,1 +BRDA:38,8,0,1 +BRDA:42,9,0,1 +BRDA:46,10,0,1 +BRDA:50,11,0,1 +BRDA:54,12,0,1 +BRDA:59,13,0,1 +BRDA:64,14,0,1 +BRDA:68,15,0,1 +BRDA:72,16,0,1 +BRDA:76,17,0,1 +BRDA:80,18,0,1 +BRDA:81,19,0,1 +BRDA:86,20,0,1 +BRDA:87,21,0,1 +BRDA:92,22,0,1 +BRDA:93,23,0,1 +BRDA:94,24,0,1 +BRDA:100,25,0,1 +BRDA:101,26,0,1 +BRDA:107,27,0,1 +BRDA:111,28,0,1 +BRDA:112,29,0,1 +BRDA:113,30,0,1 +BRDA:114,31,0,1 +BRDA:122,32,0,1 +BRDA:123,33,0,1 +BRDA:130,34,0,1 +BRDA:131,35,0,1 +BRDA:132,36,0,1 +BRDA:140,37,0,1 +BRDA:141,38,0,1 +BRDA:142,39,0,1 +BRDA:150,40,0,1 +BRDA:151,41,0,1 +BRDA:159,42,0,1 +BRDA:160,43,0,1 +BRDA:161,44,0,1 +BRDA:166,45,0,1 +BRDA:167,46,0,1 +BRDA:171,47,0,1 +BRDA:172,48,0,1 +BRDA:173,49,0,1 +BRDA:187,50,0,1 +BRDA:195,51,0,1 +BRDA:198,52,0,1 +BRDA:215,53,0,1 +BRDA:219,54,0,1 +BRDA:220,55,0,1 +BRDA:225,56,0,1 +BRDA:229,57,0,1 +BRDA:233,58,0,1 +BRDA:238,59,0,1 +BRDA:242,60,0,1 +BRDA:246,61,0,1 +BRDA:251,62,0,1 +BRDA:256,63,0,1 +BRDA:257,64,0,1 +BRDA:263,65,0,1 +BRDA:264,66,0,1 +BRDA:269,67,0,1 +BRDA:270,68,0,1 +BRDA:277,69,0,1 +BRDA:287,70,0,1 +BRDA:289,71,0,1 +BRDA:298,72,0,1 +BRDA:300,73,0,1 +BRDA:309,74,0,1 +BRDA:310,75,0,1 +BRDA:313,76,0,1 +BRDA:318,77,0,1 +BRDA:319,78,0,1 +BRDA:320,79,0,1 +BRDA:327,80,0,1 +BRDA:328,81,0,1 +BRDA:335,82,0,1 +BRDA:336,83,0,1 +BRDA:341,84,0,1 +BRDA:345,85,0,1 +BRDA:348,86,0,1 +BRDA:349,87,0,0 +BRDA:351,88,0,1 +BRDA:356,89,0,1 +BRDA:359,90,0,1 +BRDA:360,91,0,0 +BRDA:362,92,0,1 +BRDA:367,93,0,1 +BRDA:370,94,0,0 +BRDA:368,95,0,1 +BRDA:369,96,0,1 +BRDA:373,97,0,1 +BRDA:376,98,0,0 +BRDA:374,99,0,1 +BRDA:375,100,0,1 +BRDA:381,101,0,1 +BRDA:385,102,0,1 +BRF:103 +BRH:99 DA:1,1 DA:2,1 DA:3,1 @@ -518,12 +488,12 @@ DA:176,1 DA:177,1 DA:178,1 DA:179,1 -DA:180,1 -DA:181,0 +DA:180,0 +DA:181,1 DA:182,1 DA:183,1 -DA:184,1 -DA:185,0 +DA:184,0 +DA:185,1 DA:186,1 DA:187,1 DA:188,1 @@ -744,45 +714,6 @@ DA:402,1 DA:403,1 DA:404,1 DA:405,1 -DA:406,1 -DA:407,1 -DA:408,1 -DA:409,1 -DA:410,1 -DA:411,1 -DA:412,1 -DA:413,1 -DA:414,1 -DA:415,1 -DA:416,1 -DA:417,1 -DA:418,1 -DA:419,1 -DA:420,1 -DA:421,1 -DA:422,1 -DA:423,1 -DA:424,1 -DA:425,1 -DA:426,1 -DA:427,1 -DA:428,1 -DA:429,1 -DA:430,1 -DA:431,1 -DA:432,1 -DA:433,1 -DA:434,1 -DA:435,1 -DA:436,1 -DA:437,1 -DA:438,1 -DA:439,1 -DA:440,1 -DA:441,1 -DA:442,1 -DA:443,1 -DA:444,1 -LH:442 -LF:444 +LH:403 +LF:405 end_of_record diff --git a/test/fixtures/test-runner/output/output.js b/test/fixtures/test-runner/output/output.js index 83a0958761b456..ff1b2958774052 100644 --- a/test/fixtures/test-runner/output/output.js +++ b/test/fixtures/test-runner/output/output.js @@ -3,7 +3,6 @@ require('../../../common'); const assert = require('node:assert'); const test = require('node:test'); -const { describe, it } = require('node:test'); const util = require('util'); test('sync pass todo', (t) => { @@ -404,41 +403,3 @@ test('assertion errors display actual and expected properly', async () => { throw err; } }); - -describe('should NOT print --test-only diagnostic warning - describe-only-false', {only: false}, () => { - it('only false in describe'); -}); - -describe('should NOT print --test-only diagnostic warning - it-only-false', () => { - it('only false in the subtest', {only: false}); -}); - -describe('should NOT print --test-only diagnostic warning - no-only', () => { - it('no only'); -}); - -test('should NOT print --test-only diagnostic warning - test-only-false', {only: false}, async (t) => { - await t.test('only false in parent test'); -}); - -test('should NOT print --test-only diagnostic warning - t.test-only-false', async (t) => { - await t.test('only false in subtest', {only: false}); -}); - -test('should NOT print --test-only diagnostic warning - no-only', async (t) => { - await t.test('no only'); -}); - -test('should print --test-only diagnostic warning - test-only-true', {only: true}, async (t) => { - await t.test('only true in parent test'); -}) - -test('should print --test-only diagnostic warning - t.test-only-true', async (t) => { - await t.test('only true in subtest', {only: true}); -}); - -test('should print --test-only diagnostic warning - 2 levels of only', async (t) => { - await t.test('only true in parent test', {only: false}, async (t) => { - await t.test('only true in subtest', {only: true}); - }); -}) diff --git a/test/fixtures/test-runner/output/output.snapshot b/test/fixtures/test-runner/output/output.snapshot index 0df6bcbece15fc..0acb6573bc6710 100644 --- a/test/fixtures/test-runner/output/output.snapshot +++ b/test/fixtures/test-runner/output/output.snapshot @@ -699,119 +699,8 @@ not ok 61 - assertion errors display actual and expected properly stack: |- * ... -# Subtest: should NOT print --test-only diagnostic warning - describe-only-false - # Subtest: only false in describe - ok 1 - only false in describe - --- - duration_ms: * - ... - 1..1 -ok 62 - should NOT print --test-only diagnostic warning - describe-only-false - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - it-only-false - # Subtest: only false in the subtest - ok 1 - only false in the subtest - --- - duration_ms: * - ... - 1..1 -ok 63 - should NOT print --test-only diagnostic warning - it-only-false - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - no-only - # Subtest: no only - ok 1 - no only - --- - duration_ms: * - ... - 1..1 -ok 64 - should NOT print --test-only diagnostic warning - no-only - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - test-only-false - # Subtest: only false in parent test - ok 1 - only false in parent test - --- - duration_ms: * - ... - 1..1 -ok 65 - should NOT print --test-only diagnostic warning - test-only-false - --- - duration_ms: * - ... -# Subtest: should NOT print --test-only diagnostic warning - t.test-only-false - # Subtest: only false in subtest - ok 1 - only false in subtest - --- - duration_ms: * - ... - 1..1 -ok 66 - should NOT print --test-only diagnostic warning - t.test-only-false - --- - duration_ms: * - ... -# Subtest: should NOT print --test-only diagnostic warning - no-only - # Subtest: no only - ok 1 - no only - --- - duration_ms: * - ... - 1..1 -ok 67 - should NOT print --test-only diagnostic warning - no-only - --- - duration_ms: * - ... -# Subtest: should print --test-only diagnostic warning - test-only-true - # Subtest: only true in parent test - ok 1 - only true in parent test - --- - duration_ms: * - ... - 1..1 -ok 68 - should print --test-only diagnostic warning - test-only-true - --- - duration_ms: * - ... -# 'only' and 'runOnly' require the --test-only command-line option. -# Subtest: should print --test-only diagnostic warning - t.test-only-true - # Subtest: only true in subtest - ok 1 - only true in subtest - --- - duration_ms: * - ... - # 'only' and 'runOnly' require the --test-only command-line option. - 1..1 -ok 69 - should print --test-only diagnostic warning - t.test-only-true - --- - duration_ms: * - ... -# Subtest: should print --test-only diagnostic warning - 2 levels of only - # Subtest: only true in parent test - # Subtest: only true in subtest - ok 1 - only true in subtest - --- - duration_ms: * - ... - # 'only' and 'runOnly' require the --test-only command-line option. - 1..1 - ok 1 - only true in parent test - --- - duration_ms: * - ... - 1..1 -ok 70 - should print --test-only diagnostic warning - 2 levels of only - --- - duration_ms: * - ... # Subtest: invalid subtest fail -not ok 71 - invalid subtest fail +not ok 62 - invalid subtest fail --- duration_ms: * location: '/test/fixtures/test-runner/output/output.js:(LINE):7' @@ -821,7 +710,7 @@ not ok 71 - invalid subtest fail stack: |- * ... -1..71 +1..62 # Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. @@ -829,9 +718,9 @@ not ok 71 - invalid subtest fail # Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. # Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. # Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. -# tests 92 -# suites 3 -# pass 51 +# tests 76 +# suites 0 +# pass 35 # fail 25 # cancelled 3 # skipped 9 diff --git a/test/fixtures/test-runner/output/output_cli.snapshot b/test/fixtures/test-runner/output/output_cli.snapshot index 046ba16c5781d6..d04dc0a0a905ad 100644 --- a/test/fixtures/test-runner/output/output_cli.snapshot +++ b/test/fixtures/test-runner/output/output_cli.snapshot @@ -699,119 +699,8 @@ not ok 61 - assertion errors display actual and expected properly stack: |- * ... -# Subtest: should NOT print --test-only diagnostic warning - describe-only-false - # Subtest: only false in describe - ok 1 - only false in describe - --- - duration_ms: * - ... - 1..1 -ok 62 - should NOT print --test-only diagnostic warning - describe-only-false - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - it-only-false - # Subtest: only false in the subtest - ok 1 - only false in the subtest - --- - duration_ms: * - ... - 1..1 -ok 63 - should NOT print --test-only diagnostic warning - it-only-false - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - no-only - # Subtest: no only - ok 1 - no only - --- - duration_ms: * - ... - 1..1 -ok 64 - should NOT print --test-only diagnostic warning - no-only - --- - duration_ms: * - type: 'suite' - ... -# Subtest: should NOT print --test-only diagnostic warning - test-only-false - # Subtest: only false in parent test - ok 1 - only false in parent test - --- - duration_ms: * - ... - 1..1 -ok 65 - should NOT print --test-only diagnostic warning - test-only-false - --- - duration_ms: * - ... -# Subtest: should NOT print --test-only diagnostic warning - t.test-only-false - # Subtest: only false in subtest - ok 1 - only false in subtest - --- - duration_ms: * - ... - 1..1 -ok 66 - should NOT print --test-only diagnostic warning - t.test-only-false - --- - duration_ms: * - ... -# Subtest: should NOT print --test-only diagnostic warning - no-only - # Subtest: no only - ok 1 - no only - --- - duration_ms: * - ... - 1..1 -ok 67 - should NOT print --test-only diagnostic warning - no-only - --- - duration_ms: * - ... -# Subtest: should print --test-only diagnostic warning - test-only-true - # Subtest: only true in parent test - ok 1 - only true in parent test - --- - duration_ms: * - ... - 1..1 -ok 68 - should print --test-only diagnostic warning - test-only-true - --- - duration_ms: * - ... -# 'only' and 'runOnly' require the --test-only command-line option. -# Subtest: should print --test-only diagnostic warning - t.test-only-true - # Subtest: only true in subtest - ok 1 - only true in subtest - --- - duration_ms: * - ... - # 'only' and 'runOnly' require the --test-only command-line option. - 1..1 -ok 69 - should print --test-only diagnostic warning - t.test-only-true - --- - duration_ms: * - ... -# Subtest: should print --test-only diagnostic warning - 2 levels of only - # Subtest: only true in parent test - # Subtest: only true in subtest - ok 1 - only true in subtest - --- - duration_ms: * - ... - # 'only' and 'runOnly' require the --test-only command-line option. - 1..1 - ok 1 - only true in parent test - --- - duration_ms: * - ... - 1..1 -ok 70 - should print --test-only diagnostic warning - 2 levels of only - --- - duration_ms: * - ... # Subtest: invalid subtest fail -not ok 71 - invalid subtest fail +not ok 62 - invalid subtest fail --- duration_ms: * location: '/test/fixtures/test-runner/output/output.js:(LINE):7' @@ -829,14 +718,14 @@ not ok 71 - invalid subtest fail # Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. # Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:(LINE):1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. # Subtest: last test -ok 72 - last test +ok 63 - last test --- duration_ms: * ... -1..72 -# tests 93 -# suites 3 -# pass 52 +1..63 +# tests 77 +# suites 0 +# pass 36 # fail 25 # cancelled 3 # skipped 9 diff --git a/test/fixtures/test-runner/output/spec_reporter.snapshot b/test/fixtures/test-runner/output/spec_reporter.snapshot index 53f526b9320e43..f37d7f35b8a7d6 100644 --- a/test/fixtures/test-runner/output/spec_reporter.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter.snapshot @@ -294,51 +294,19 @@ operator: 'deepEqual' } - should NOT print --test-only diagnostic warning - describe-only-false - only false in describe (*ms) - should NOT print --test-only diagnostic warning - describe-only-false (*ms) - should NOT print --test-only diagnostic warning - it-only-false - only false in the subtest (*ms) - should NOT print --test-only diagnostic warning - it-only-false (*ms) - should NOT print --test-only diagnostic warning - no-only - no only (*ms) - should NOT print --test-only diagnostic warning - no-only (*ms) - should NOT print --test-only diagnostic warning - test-only-false - only false in parent test (*ms) - should NOT print --test-only diagnostic warning - test-only-false (*ms) - should NOT print --test-only diagnostic warning - t.test-only-false - only false in subtest (*ms) - should NOT print --test-only diagnostic warning - t.test-only-false (*ms) - should NOT print --test-only diagnostic warning - no-only - no only (*ms) - should NOT print --test-only diagnostic warning - no-only (*ms) - should print --test-only diagnostic warning - test-only-true - only true in parent test (*ms) - should print --test-only diagnostic warning - test-only-true (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - should print --test-only diagnostic warning - t.test-only-true - only true in subtest (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - should print --test-only diagnostic warning - t.test-only-true (*ms) - should print --test-only diagnostic warning - 2 levels of only - only true in parent test - only true in subtest (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - only true in parent test (*ms) - should print --test-only diagnostic warning - 2 levels of only (*ms) invalid subtest fail (*ms) 'test could not be started because its parent finished' - Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:73:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:77:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. - Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:81:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:87:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:252:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:270:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. - tests 92 - suites 3 - pass 51 + Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:80:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:86:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:251:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:269:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. + tests 76 + suites 0 + pass 35 fail 25 cancelled 3 skipped 9 diff --git a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot index 675a1dc8d7434a..d8648bfe03a8be 100644 --- a/test/fixtures/test-runner/output/spec_reporter_cli.snapshot +++ b/test/fixtures/test-runner/output/spec_reporter_cli.snapshot @@ -294,51 +294,19 @@ operator: 'deepEqual' } - should NOT print --test-only diagnostic warning - describe-only-false - only false in describe (*ms) - should NOT print --test-only diagnostic warning - describe-only-false (*ms) - should NOT print --test-only diagnostic warning - it-only-false - only false in the subtest (*ms) - should NOT print --test-only diagnostic warning - it-only-false (*ms) - should NOT print --test-only diagnostic warning - no-only - no only (*ms) - should NOT print --test-only diagnostic warning - no-only (*ms) - should NOT print --test-only diagnostic warning - test-only-false - only false in parent test (*ms) - should NOT print --test-only diagnostic warning - test-only-false (*ms) - should NOT print --test-only diagnostic warning - t.test-only-false - only false in subtest (*ms) - should NOT print --test-only diagnostic warning - t.test-only-false (*ms) - should NOT print --test-only diagnostic warning - no-only - no only (*ms) - should NOT print --test-only diagnostic warning - no-only (*ms) - should print --test-only diagnostic warning - test-only-true - only true in parent test (*ms) - should print --test-only diagnostic warning - test-only-true (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - should print --test-only diagnostic warning - t.test-only-true - only true in subtest (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - should print --test-only diagnostic warning - t.test-only-true (*ms) - should print --test-only diagnostic warning - 2 levels of only - only true in parent test - only true in subtest (*ms) - 'only' and 'runOnly' require the --test-only command-line option. - only true in parent test (*ms) - should print --test-only diagnostic warning - 2 levels of only (*ms) invalid subtest fail (*ms) 'test could not be started because its parent finished' - Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:73:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:77:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. Error: A resource generated asynchronous activity after the test ended. This activity created the error "Error: uncaught from outside of a test" which triggered an uncaughtException event, caught by the test runner. - Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:81:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:87:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. - Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:252:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. - Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:270:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. - tests 92 - suites 3 - pass 51 + Error: Test "immediate throw - passes but warns" at test/fixtures/test-runner/output/output.js:80:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "immediate reject - passes but warns" at test/fixtures/test-runner/output/output.js:86:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event. + Error: Test "callback called twice in different ticks" at test/fixtures/test-runner/output/output.js:251:1 generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event. + Error: Test "callback async throw after done" at test/fixtures/test-runner/output/output.js:269:1 generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. + tests 76 + suites 0 + pass 35 fail 25 cancelled 3 skipped 9 diff --git a/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.js b/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.js new file mode 100644 index 00000000000000..cf6018deadbd2f --- /dev/null +++ b/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.js @@ -0,0 +1,40 @@ +'use strict'; +const { test, describe, it } = require('node:test'); + +describe('should NOT print --test-only diagnostic warning - describe-only-false', {only: false}, () => { + it('only false in describe'); + }); + + describe('should NOT print --test-only diagnostic warning - it-only-false', () => { + it('only false in the subtest', {only: false}); + }); + + describe('should NOT print --test-only diagnostic warning - no-only', () => { + it('no only'); + }); + + test('should NOT print --test-only diagnostic warning - test-only-false', {only: false}, async (t) => { + await t.test('only false in parent test'); + }); + + test('should NOT print --test-only diagnostic warning - t.test-only-false', async (t) => { + await t.test('only false in subtest', {only: false}); + }); + + test('should NOT print --test-only diagnostic warning - no-only', async (t) => { + await t.test('no only'); + }); + + test('should print --test-only diagnostic warning - test-only-true', {only: true}, async (t) => { + await t.test('only true in parent test'); + }) + + test('should print --test-only diagnostic warning - t.test-only-true', async (t) => { + await t.test('only true in subtest', {only: true}); + }); + + test('should print --test-only diagnostic warning - 2 levels of only', async (t) => { + await t.test('only true in parent test', {only: false}, async (t) => { + await t.test('only true in subtest', {only: true}); + }); + }) diff --git a/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.snapshot b/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.snapshot new file mode 100644 index 00000000000000..c64caa87a279e8 --- /dev/null +++ b/test/fixtures/test-runner/output/test-diagnostic-warning-without-test-only-flag.snapshot @@ -0,0 +1,121 @@ +TAP version 13 +# Subtest: should NOT print --test-only diagnostic warning - describe-only-false + # Subtest: only false in describe + ok 1 - only false in describe + --- + duration_ms: * + ... + 1..1 +ok 1 - should NOT print --test-only diagnostic warning - describe-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - it-only-false + # Subtest: only false in the subtest + ok 1 - only false in the subtest + --- + duration_ms: * + ... + 1..1 +ok 2 - should NOT print --test-only diagnostic warning - it-only-false + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 3 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + type: 'suite' + ... +# Subtest: should NOT print --test-only diagnostic warning - test-only-false + # Subtest: only false in parent test + ok 1 - only false in parent test + --- + duration_ms: * + ... + 1..1 +ok 4 - should NOT print --test-only diagnostic warning - test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - t.test-only-false + # Subtest: only false in subtest + ok 1 - only false in subtest + --- + duration_ms: * + ... + 1..1 +ok 5 - should NOT print --test-only diagnostic warning - t.test-only-false + --- + duration_ms: * + ... +# Subtest: should NOT print --test-only diagnostic warning - no-only + # Subtest: no only + ok 1 - no only + --- + duration_ms: * + ... + 1..1 +ok 6 - should NOT print --test-only diagnostic warning - no-only + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - test-only-true + # Subtest: only true in parent test + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 7 - should print --test-only diagnostic warning - test-only-true + --- + duration_ms: * + ... +# 'only' and 'runOnly' require the --test-only command-line option. +# Subtest: should print --test-only diagnostic warning - t.test-only-true + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 +ok 8 - should print --test-only diagnostic warning - t.test-only-true + --- + duration_ms: * + ... +# Subtest: should print --test-only diagnostic warning - 2 levels of only + # Subtest: only true in parent test + # Subtest: only true in subtest + ok 1 - only true in subtest + --- + duration_ms: * + ... + # 'only' and 'runOnly' require the --test-only command-line option. + 1..1 + ok 1 - only true in parent test + --- + duration_ms: * + ... + 1..1 +ok 9 - should print --test-only diagnostic warning - 2 levels of only + --- + duration_ms: * + ... +1..9 +# tests 16 +# suites 3 +# pass 16 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms * diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs index 676168e9df4e50..e0fbb5f9b432df 100644 --- a/test/parallel/test-runner-output.mjs +++ b/test/parallel/test-runner-output.mjs @@ -146,6 +146,7 @@ const tests = [ }, { name: 'test-runner/output/test-runner-plan.js' }, process.features.inspector ? { name: 'test-runner/output/coverage_failure.js' } : false, + { name: 'test-runner/output/test-diagnostic-warning-without-test-only-flag.js' }, ] .filter(Boolean) .map(({ name, tty, transform }) => ({