From 846e2b289601160b08b92949dc42758fc3b948cd Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 26 Aug 2024 20:54:22 -0400 Subject: [PATCH] test: refactor test_runner tests to change default reporter This commit updates the test runner tests in order to switch the default reporter from tap to spec. This commit can be backported, while changing the default reporter cannot. Refs: https://github.com/nodejs/node/issues/54540 PR-URL: https://github.com/nodejs/node/pull/54547 Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Moshe Atlow Reviewed-By: Jake Yuesong Li --- test/common/assertSnapshot.js | 6 +- test/parallel/test-runner-cli.js | 24 ++- test/parallel/test-runner-exit-code.js | 10 +- .../test-runner-extraneous-async-activity.js | 44 ++--- .../test-runner-force-exit-failure.js | 3 +- test/parallel/test-runner-inspect.mjs | 7 +- test/parallel/test-runner-misc.js | 6 +- test/parallel/test-runner-module-mocking.js | 2 +- .../test-runner-no-isolation-filtering.js | 3 + test/parallel/test-runner-output.mjs | 184 ++++++++++++++---- test/parallel/test-runner-root-duration.js | 1 + test/parallel/test-runner-snapshot-tests.js | 12 +- .../test-runner-watch-mode-complex.mjs | 18 +- 13 files changed, 220 insertions(+), 100 deletions(-) diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index a22455160bd9f7..e0793ce5394cda 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -77,7 +77,11 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... test({ skip: 'Skipping pseudo-tty tests, as pseudo terminals are not available on Windows.' }); return; } - const flags = common.parseTestFlags(filename); + let flags = common.parseTestFlags(filename); + if (options.flags) { + flags = [...options.flags, ...flags]; + } + const executable = tty ? (process.env.PYTHON || 'python3') : process.execPath; const args = tty ? diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index d2d2eea8809404..8610d512561dff 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -26,7 +26,8 @@ for (const isolation of ['none', 'process']) { { // Default behavior. node_modules is ignored. Files that don't match the // pattern are ignored except in test/ directories. - const args = ['--test', `--experimental-test-isolation=${isolation}`]; + const args = ['--test', '--test-reporter=tap', + `--experimental-test-isolation=${isolation}`]; const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); assert.strictEqual(child.status, 1); @@ -47,6 +48,7 @@ for (const isolation of ['none', 'process']) { const args = [ '--require', join(testFixtures, 'protoMutation.js'), '--test', + '--test-reporter=tap', `--experimental-test-isolation=${isolation}`, ]; const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') }); @@ -67,6 +69,7 @@ for (const isolation of ['none', 'process']) { // User specified files that don't match the pattern are still run. const args = [ '--test', + '--test-reporter=tap', `--experimental-test-isolation=${isolation}`, join(testFixtures, 'index.js'), ]; @@ -83,6 +86,7 @@ for (const isolation of ['none', 'process']) { // Searches node_modules if specified. const args = [ '--test', + '--test-reporter=tap', `--experimental-test-isolation=${isolation}`, join(testFixtures, 'default-behavior/node_modules/*.js'), ]; @@ -105,18 +109,19 @@ for (const isolation of ['none', 'process']) { assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert.match(stdout, /ok 1 - this should pass/); - assert.match(stdout, /not ok 2 - this should fail/); - assert.match(stdout, /ok 3 - subdir.+subdir_test\.js/); - assert.match(stdout, /ok 4 - this should pass/); - assert.match(stdout, /ok 5 - this should be skipped/); - assert.match(stdout, /ok 6 - this should be executed/); + assert.match(stdout, /this should pass/); + assert.match(stdout, /this should fail/); + assert.match(stdout, /subdir.+subdir_test\.js/); + assert.match(stdout, /this should pass/); + assert.match(stdout, /this should be skipped/); + assert.match(stdout, /this should be executed/); } { // Test combined stream outputs const args = [ '--test', + '--test-reporter=tap', `--experimental-test-isolation=${isolation}`, 'test/fixtures/test-runner/default-behavior/index.test.js', 'test/fixtures/test-runner/nested.js', @@ -189,6 +194,7 @@ for (const isolation of ['none', 'process']) { // Test user logging in tests. const args = [ '--test', + '--test-reporter=tap', 'test/fixtures/test-runner/user-logs.js', ]; const child = spawnSync(process.execPath, args); @@ -223,7 +229,7 @@ for (const isolation of ['none', 'process']) { assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); const stdout = child.stdout.toString(); - assert.match(stdout, /ok 1 - this should pass/); + assert.match(stdout, /this should pass/); } { @@ -290,6 +296,7 @@ for (const isolation of ['none', 'process']) { // --test-shard option, first shard const args = [ '--test', + '--test-reporter=tap', '--test-shard=1/2', join(testFixtures, 'shards/*.cjs'), ]; @@ -324,6 +331,7 @@ for (const isolation of ['none', 'process']) { // --test-shard option, last shard const args = [ '--test', + '--test-reporter=tap', '--test-shard=2/2', join(testFixtures, 'shards/*.cjs'), ]; diff --git a/test/parallel/test-runner-exit-code.js b/test/parallel/test-runner-exit-code.js index 700480386d5b4a..d2f0251e5fb30c 100644 --- a/test/parallel/test-runner-exit-code.js +++ b/test/parallel/test-runner-exit-code.js @@ -12,7 +12,7 @@ async function runAndKill(file) { return; } let stdout = ''; - const child = spawn(process.execPath, ['--test', file]); + const child = spawn(process.execPath, ['--test', '--test-reporter=tap', file]); child.stdout.setEncoding('utf8'); child.stdout.on('data', (chunk) => { if (!stdout.length) child.kill('SIGINT'); @@ -58,10 +58,10 @@ if (process.argv[2] === 'child') { assert.strictEqual(child.status, 0); assert.strictEqual(child.signal, null); const stdout = child.stdout.toString(); - assert.match(stdout, /# tests 3/); - assert.match(stdout, /# pass 0/); - assert.match(stdout, /# fail 0/); - assert.match(stdout, /# todo 3/); + assert.match(stdout, /tests 3/); + assert.match(stdout, /pass 0/); + assert.match(stdout, /fail 0/); + assert.match(stdout, /todo 3/); child = spawnSync(process.execPath, [__filename, 'child', 'fail']); assert.strictEqual(child.status, 1); diff --git a/test/parallel/test-runner-extraneous-async-activity.js b/test/parallel/test-runner-extraneous-async-activity.js index 23f3194e02f106..58593fe70bbe10 100644 --- a/test/parallel/test-runner-extraneous-async-activity.js +++ b/test/parallel/test-runner-extraneous-async-activity.js @@ -10,10 +10,10 @@ const { spawnSync } = require('child_process'); fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs'), ]); const stdout = child.stdout.toString(); - assert.match(stdout, /^# Error: Test "extraneous async activity test" at .+extraneous_set_immediate_async\.mjs:3:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# pass 1/m); - assert.match(stdout, /^# fail 1$/m); - assert.match(stdout, /^# cancelled 0$/m); + assert.match(stdout, /Error: Test "extraneous async activity test" at .+extraneous_set_immediate_async\.mjs:3:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /pass 1/m); + assert.match(stdout, /fail 1$/m); + assert.match(stdout, /cancelled 0$/m); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); } @@ -24,10 +24,10 @@ const { spawnSync } = require('child_process'); fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs'), ]); const stdout = child.stdout.toString(); - assert.match(stdout, /^# Error: Test "extraneous async activity test" at .+extraneous_set_timeout_async\.mjs:3:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# pass 1$/m); - assert.match(stdout, /^# fail 1$/m); - assert.match(stdout, /^# cancelled 0$/m); + assert.match(stdout, /Error: Test "extraneous async activity test" at .+extraneous_set_timeout_async\.mjs:3:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /pass 1$/m); + assert.match(stdout, /fail 1$/m); + assert.match(stdout, /cancelled 0$/m); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); } @@ -38,13 +38,13 @@ const { spawnSync } = require('child_process'); fixtures.path('test-runner', 'async-error-in-test-hook.mjs'), ]); const stdout = child.stdout.toString(); - assert.match(stdout, /^# Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# pass 1$/m); - assert.match(stdout, /^# fail 1$/m); - assert.match(stdout, /^# cancelled 0$/m); + assert.match(stdout, /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /pass 1$/m); + assert.match(stdout, /fail 1$/m); + assert.match(stdout, /cancelled 0$/m); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); } @@ -56,13 +56,13 @@ const { spawnSync } = require('child_process'); fixtures.path('test-runner', 'async-error-in-test-hook.mjs'), ]); const stdout = child.stdout.toString(); - assert.match(stdout, /^# Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m); - assert.match(stdout, /^# pass 1$/m); - assert.match(stdout, /^# fail 0$/m); - assert.match(stdout, /^# cancelled 0$/m); + assert.match(stdout, /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m); + assert.match(stdout, /pass 1$/m); + assert.match(stdout, /fail 0$/m); + assert.match(stdout, /cancelled 0$/m); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); } diff --git a/test/parallel/test-runner-force-exit-failure.js b/test/parallel/test-runner-force-exit-failure.js index ce1f3208c5b4e6..ae2b21d7c61dc0 100644 --- a/test/parallel/test-runner-force-exit-failure.js +++ b/test/parallel/test-runner-force-exit-failure.js @@ -8,6 +8,7 @@ const fixture = fixtures.path('test-runner/throws_sync_and_async.js'); for (const isolation of ['none', 'process']) { const args = [ '--test', + '--test-reporter=spec', '--test-force-exit', `--experimental-test-isolation=${isolation}`, fixture, @@ -19,6 +20,6 @@ for (const isolation of ['none', 'process']) { strictEqual(r.stderr.toString(), ''); const stdout = r.stdout.toString(); - match(stdout, /error: 'fails'/); + match(stdout, /Error: fails/); doesNotMatch(stdout, /this should not have a chance to be thrown/); } diff --git a/test/parallel/test-runner-inspect.mjs b/test/parallel/test-runner-inspect.mjs index e4e6a7d35f4810..2161959498f15c 100644 --- a/test/parallel/test-runner-inspect.mjs +++ b/test/parallel/test-runner-inspect.mjs @@ -12,7 +12,7 @@ tmpdir.refresh(); { const child = new NodeInstance( - ['--test', '--inspect-brk=0'], + ['--test', '--test-reporter=tap', '--inspect-brk=0'], undefined, fixtures.path('test-runner/default-behavior/index.test.js') ); @@ -38,7 +38,10 @@ tmpdir.refresh(); { - const args = ['--test', '--inspect=0', fixtures.path('test-runner/index.js')]; + const args = [ + '--test', '--test-reporter=tap', '--inspect=0', + fixtures.path('test-runner/index.js'), + ]; const { stderr, stdout, code, signal } = await common.spawnPromisified(process.execPath, args); assert.match(stderr, diff --git a/test/parallel/test-runner-misc.js b/test/parallel/test-runner-misc.js index abc2715dcfba48..cea115493249a1 100644 --- a/test/parallel/test-runner-misc.js +++ b/test/parallel/test-runner-misc.js @@ -33,9 +33,9 @@ if (process.argv[2] === 'child') { } else { const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']); const stdout = child.stdout.toString(); - assert.match(stdout, /^# pass 2$/m); - assert.match(stdout, /^# fail 0$/m); - assert.match(stdout, /^# cancelled 1$/m); + assert.match(stdout, /pass 2$/m); + assert.match(stdout, /fail 0$/m); + assert.match(stdout, /cancelled 1$/m); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); } diff --git a/test/parallel/test-runner-module-mocking.js b/test/parallel/test-runner-module-mocking.js index 45345815c69db4..f36dc13915b51a 100644 --- a/test/parallel/test-runner-module-mocking.js +++ b/test/parallel/test-runner-module-mocking.js @@ -571,7 +571,7 @@ test('node_modules can be used by both module systems', async (t) => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); - assert.match(stdout, /# pass 1/); + assert.match(stdout, /pass 1/); }); test('file:// imports are supported in ESM only', async (t) => { diff --git a/test/parallel/test-runner-no-isolation-filtering.js b/test/parallel/test-runner-no-isolation-filtering.js index f8fba1cbfffbef..21db267d5323c6 100644 --- a/test/parallel/test-runner-no-isolation-filtering.js +++ b/test/parallel/test-runner-no-isolation-filtering.js @@ -11,6 +11,7 @@ const fixture2 = fixtures.path('test-runner', 'no-isolation', 'two.test.js'); test('works with --test-only', () => { const args = [ '--test', + '--test-reporter=tap', '--experimental-test-isolation=none', '--test-only', fixture1, @@ -33,6 +34,7 @@ test('works with --test-only', () => { test('works with --test-name-pattern', () => { const args = [ '--test', + '--test-reporter=tap', '--experimental-test-isolation=none', '--test-name-pattern=/test one/', fixture1, @@ -52,6 +54,7 @@ test('works with --test-name-pattern', () => { test('works with --test-skip-pattern', () => { const args = [ '--test', + '--test-reporter=tap', '--experimental-test-isolation=none', '--test-skip-pattern=/one/', fixture1, diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs index 47e0f211f34a0d..6de1c2eeafce98 100644 --- a/test/parallel/test-runner-output.mjs +++ b/test/parallel/test-runner-output.mjs @@ -92,50 +92,116 @@ const lcovTransform = snapshot.transform( const tests = [ - { name: 'test-runner/output/abort.js' }, - { name: 'test-runner/output/abort-runs-after-hook.js' }, - { name: 'test-runner/output/abort_suite.js' }, - { name: 'test-runner/output/abort_hooks.js' }, - { name: 'test-runner/output/describe_it.js' }, - { name: 'test-runner/output/describe_nested.js' }, + { name: 'test-runner/output/abort.js', flags: ['--test-reporter=tap'] }, + { + name: 'test-runner/output/abort-runs-after-hook.js', + flags: ['--test-reporter=tap'], + }, + { name: 'test-runner/output/abort_suite.js', flags: ['--test-reporter=tap'] }, + { name: 'test-runner/output/abort_hooks.js', flags: ['--test-reporter=tap'] }, + { name: 'test-runner/output/describe_it.js', flags: ['--test-reporter=tap'] }, + { + name: 'test-runner/output/describe_nested.js', + flags: ['--test-reporter=tap'], + }, { name: 'test-runner/output/eval_dot.js', transform: specTransform }, { name: 'test-runner/output/eval_spec.js', transform: specTransform }, { name: 'test-runner/output/eval_tap.js' }, - { name: 'test-runner/output/filtered-suite-delayed-build.js' }, - { name: 'test-runner/output/filtered-suite-order.mjs' }, - { name: 'test-runner/output/filtered-suite-throws.js' }, - { name: 'test-runner/output/hooks.js' }, + { + name: 'test-runner/output/filtered-suite-delayed-build.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/filtered-suite-order.mjs', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/filtered-suite-throws.js', + flags: ['--test-reporter=tap'], + }, + { name: 'test-runner/output/hooks.js', flags: ['--test-reporter=tap'] }, { name: 'test-runner/output/hooks_spec_reporter.js', transform: specTransform }, { name: 'test-runner/output/skip-each-hooks.js', transform: specTransform }, { name: 'test-runner/output/suite-skip-hooks.js', transform: specTransform }, - { name: 'test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js' }, - { name: 'test-runner/output/hooks-with-no-global-test.js' }, - { name: 'test-runner/output/global-hooks-with-no-tests.js' }, - { name: 'test-runner/output/before-and-after-each-too-many-listeners.js' }, - { name: 'test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js' }, + { + name: 'test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/hooks-with-no-global-test.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/global-hooks-with-no-tests.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/before-and-after-each-too-many-listeners.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js', + flags: ['--test-reporter=tap'], + }, { name: 'test-runner/output/force_exit.js', transform: specTransform }, - { name: 'test-runner/output/global_after_should_fail_the_test.js' }, - { name: 'test-runner/output/no_refs.js' }, - { name: 'test-runner/output/no_tests.js' }, - { name: 'test-runner/output/only_tests.js' }, + { + name: 'test-runner/output/global_after_should_fail_the_test.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/no_refs.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/no_tests.js', + flags: ['--test-reporter=tap'], + }, + { name: 'test-runner/output/only_tests.js', flags: ['--test-reporter=tap'] }, { name: 'test-runner/output/dot_reporter.js', transform: specTransform }, { name: 'test-runner/output/junit_reporter.js', transform: junitTransform }, { name: 'test-runner/output/spec_reporter_successful.js', transform: specTransform }, { name: 'test-runner/output/spec_reporter.js', transform: specTransform }, { name: 'test-runner/output/spec_reporter_cli.js', transform: specTransform }, - { name: 'test-runner/output/source_mapped_locations.mjs' }, + { + name: 'test-runner/output/source_mapped_locations.mjs', + flags: ['--test-reporter=tap'], + }, process.features.inspector ? { name: 'test-runner/output/lcov_reporter.js', transform: lcovTransform } : false, - { name: 'test-runner/output/output.js' }, + { name: 'test-runner/output/output.js', flags: ['--test-reporter=tap'] }, { name: 'test-runner/output/output_cli.js' }, - { name: 'test-runner/output/name_and_skip_patterns.js' }, - { name: 'test-runner/output/name_pattern.js' }, - { name: 'test-runner/output/name_pattern_with_only.js' }, - { name: 'test-runner/output/skip_pattern.js' }, - { name: 'test-runner/output/unfinished-suite-async-error.js' }, - { name: 'test-runner/output/unresolved_promise.js' }, + { + name: 'test-runner/output/name_and_skip_patterns.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/name_pattern.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/name_pattern_with_only.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/skip_pattern.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/unfinished-suite-async-error.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/unresolved_promise.js', + flags: ['--test-reporter=tap'], + }, { name: 'test-runner/output/default_output.js', transform: specTransform, tty: true }, - { name: 'test-runner/output/arbitrary-output.js' }, - { name: 'test-runner/output/async-test-scheduling.mjs' }, + { + name: 'test-runner/output/arbitrary-output.js', + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/async-test-scheduling.mjs', + flags: ['--test-reporter=tap'], + }, !skipForceColors ? { name: 'test-runner/output/arbitrary-output-colored.js', transform: snapshot.transform(specTransform, replaceTestDuration), tty: true @@ -147,24 +213,58 @@ const tests = [ snapshot.replaceWindowsLineEndings, replaceTestDuration, ), + flags: ['--test-reporter=tap'], + }, + { + name: 'test-runner/output/test-runner-plan.js', + flags: ['--test-reporter=tap'], }, - { 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' }, - process.features.inspector ? { name: 'test-runner/output/coverage-width-80.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-100.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-150.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-infinity.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-80-uncovered-lines.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-100-uncovered-lines.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-150-uncovered-lines.mjs' } : false, - process.features.inspector ? { name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs' } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage_failure.js', + flags: ['--test-reporter=tap'], + } : false, + { + name: 'test-runner/output/test-diagnostic-warning-without-test-only-flag.js', + flags: ['--test-reporter=tap'], + }, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-80.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-100.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-150.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-infinity.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-80-uncovered-lines.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-100-uncovered-lines.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-150-uncovered-lines.mjs', + flags: ['--test-reporter=tap'], + } : false, + process.features.inspector ? { + name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs', + flags: ['--test-reporter=tap'], + } : false, ] .filter(Boolean) -.map(({ name, tty, transform }) => ({ +.map(({ flags, name, tty, transform }) => ({ name, fn: common.mustCall(async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty }); + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags }); }), })); diff --git a/test/parallel/test-runner-root-duration.js b/test/parallel/test-runner-root-duration.js index 0c1b69359cc497..73718a8bf00be0 100644 --- a/test/parallel/test-runner-root-duration.js +++ b/test/parallel/test-runner-root-duration.js @@ -10,6 +10,7 @@ test('root duration is longer than test duration', async () => { stderr, stdout, } = await spawnPromisified(process.execPath, [ + '--test-reporter=tap', fixtures.path('test-runner/root-duration.mjs'), ]); diff --git a/test/parallel/test-runner-snapshot-tests.js b/test/parallel/test-runner-snapshot-tests.js index 62ebdd3cade2fb..bad3645f5fa183 100644 --- a/test/parallel/test-runner-snapshot-tests.js +++ b/test/parallel/test-runner-snapshot-tests.js @@ -305,9 +305,9 @@ test('t.assert.snapshot()', async (t) => { t.assert.strictEqual(child.code, 1); t.assert.strictEqual(child.signal, null); - t.assert.match(child.stdout, /# tests 5/); - t.assert.match(child.stdout, /# pass 0/); - t.assert.match(child.stdout, /# fail 5/); + t.assert.match(child.stdout, /tests 5/); + t.assert.match(child.stdout, /pass 0/); + t.assert.match(child.stdout, /fail 5/); t.assert.match(child.stdout, /Missing snapshots/); }); @@ -362,9 +362,9 @@ test('snapshots from multiple files (isolation=none)', async (t) => { t.assert.strictEqual(child.code, 1); t.assert.strictEqual(child.signal, null); - t.assert.match(child.stdout, /# tests 6/); - t.assert.match(child.stdout, /# pass 0/); - t.assert.match(child.stdout, /# fail 6/); + t.assert.match(child.stdout, /tests 6/); + t.assert.match(child.stdout, /pass 0/); + t.assert.match(child.stdout, /fail 6/); t.assert.match(child.stdout, /Missing snapshots/); }); diff --git a/test/parallel/test-runner-watch-mode-complex.mjs b/test/parallel/test-runner-watch-mode-complex.mjs index 62966d57964276..0ec9a225c3501c 100644 --- a/test/parallel/test-runner-watch-mode-complex.mjs +++ b/test/parallel/test-runner-watch-mode-complex.mjs @@ -63,7 +63,7 @@ describe('test runner watch mode with more complex setup', () => { child.stdout.on('data', (data) => { stdout += data.toString(); currentRun += data.toString(); - const testRuns = stdout.match(/# duration_ms\s\d+/g); + const testRuns = stdout.match(/duration_ms\s\d+/g); if (testRuns?.length >= 2) { ran2.resolve(); @@ -91,14 +91,14 @@ describe('test runner watch mode with more complex setup', () => { const [firstRun, secondRun] = runs; - assert.match(firstRun, /# tests 3/); - assert.match(firstRun, /# pass 3/); - assert.match(firstRun, /# fail 0/); - assert.match(firstRun, /# cancelled 0/); + assert.match(firstRun, /tests 3/); + assert.match(firstRun, /pass 3/); + assert.match(firstRun, /fail 0/); + assert.match(firstRun, /cancelled 0/); - assert.match(secondRun, /# tests 2/); - assert.match(secondRun, /# pass 2/); - assert.match(secondRun, /# fail 0/); - assert.match(secondRun, /# cancelled 0/); + assert.match(secondRun, /tests 2/); + assert.match(secondRun, /pass 2/); + assert.match(secondRun, /fail 0/); + assert.match(secondRun, /cancelled 0/); }); });