diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index 16509f12ee89fc..0e350cd1dac6fa 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -4,6 +4,7 @@ const path = require('node:path'); const test = require('node:test'); const fs = require('node:fs/promises'); const assert = require('node:assert/strict'); +const { hostname } = require('node:os'); const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g; const windowNewlineRegexp = /\r/g; @@ -100,6 +101,97 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... await assertSnapshot(transform(`${stdout}${stderr}`), filename); } +function replaceTestDuration(str) { + return str + .replaceAll(/duration_ms: [0-9.]+/g, 'duration_ms: *') + .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *'); +} + +const root = path.resolve(__dirname, '..', '..'); +const color = '(\\[\\d+m)'; +const stackTraceBasePath = new RegExp(`${color}\\(${root.replaceAll(/[\\^$*+?.()|[\]{}]/g, '\\$&')}/?${color}(.*)${color}\\)`, 'g'); + +function replaceSpecDuration(str) { + return str + .replaceAll(/[0-9.]+ms/g, '*ms') + .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *') + .replace(stackTraceBasePath, '$3'); +} + +function replaceJunitDuration(str) { + return str + .replaceAll(/time="[0-9.]+"/g, 'time="*"') + .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *') + .replaceAll(`hostname="${hostname()}"`, 'hostname="HOSTNAME"') + .replaceAll(/file="[^"]*"/g, 'file="*"') + .replace(stackTraceBasePath, '$3'); +} + +function removeWindowsPathEscaping(str) { + return common.isWindows ? str.replaceAll(/\\\\/g, '\\') : str; +} + +function replaceTestLocationLine(str) { + return str.replaceAll(/(js:)(\d+)(:\d+)/g, '$1(LINE)$3'); +} + +// The Node test coverage returns results for all files called by the test. This +// will make the output file change if files like test/common/index.js change. +// This transform picks only the first line and then the lines from the test +// file. +function pickTestFileFromLcov(str) { + const lines = str.split(/\n/); + const firstLineOfTestFile = lines.findIndex( + (line) => line.startsWith('SF:') && line.trim().endsWith('output.js'), + ); + const lastLineOfTestFile = lines.findIndex( + (line, index) => index > firstLineOfTestFile && line.trim() === 'end_of_record', + ); + return ( + lines[0] + '\n' + lines.slice(firstLineOfTestFile, lastLineOfTestFile + 1).join('\n') + '\n' + ); +} + +const defaultTransform = transform( + replaceWindowsLineEndings, + replaceStackTrace, + removeWindowsPathEscaping, + transformProjectRoot(), + replaceWindowsPaths, + replaceTestDuration, + replaceTestLocationLine, +); +const specTransform = transform( + replaceSpecDuration, + replaceWindowsLineEndings, + replaceStackTrace, + replaceWindowsPaths, +); +const junitTransform = transform( + replaceJunitDuration, + replaceWindowsLineEndings, + replaceStackTrace, + replaceWindowsPaths, +); +const lcovTransform = transform( + replaceWindowsLineEndings, + replaceStackTrace, + transformProjectRoot(), + replaceWindowsPaths, + pickTestFileFromLcov, +); + +function ensureCwdIsProjectRoot() { + if (process.cwd() !== root) { + process.chdir(root); + } +} + +function canColorize() { + // Loading it lazily to avoid breaking `NODE_REGENERATE_SNAPSHOTS`. + return require('internal/tty').getColorDepth() > 2; +} + module.exports = { assertSnapshot, getSnapshotPath, @@ -111,4 +203,11 @@ module.exports = { spawnAndAssert, transform, transformProjectRoot, + replaceTestDuration, + defaultTransform, + specTransform, + junitTransform, + lcovTransform, + ensureCwdIsProjectRoot, + canColorize, }; diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs deleted file mode 100644 index f854447c4526b1..00000000000000 --- a/test/parallel/test-runner-output.mjs +++ /dev/null @@ -1,358 +0,0 @@ -// Flags: --expose-internals -import * as common from '../common/index.mjs'; -import * as fixtures from '../common/fixtures.mjs'; -import * as snapshot from '../common/assertSnapshot.js'; -import { describe, it } from 'node:test'; -import { hostname } from 'node:os'; -import { chdir, cwd } from 'node:process'; -import { fileURLToPath } from 'node:url'; - -const skipForceColors = - process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' || - process.config.variables.node_shared_openssl; - -// We're using dynamic import here to not break `NODE_REGENERATE_SNAPSHOTS`. -const canColorize = (await import('internal/tty')).default.getColorDepth() > 2; -const skipCoverageColors = !canColorize; - -function replaceTestDuration(str) { - return str - .replaceAll(/duration_ms: [0-9.]+/g, 'duration_ms: *') - .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *'); -} - -const root = fileURLToPath(new URL('../..', import.meta.url)).slice(0, -1); - -const color = '(\\[\\d+m)'; -const stackTraceBasePath = new RegExp(`${color}\\(${root.replaceAll(/[\\^$*+?.()|[\]{}]/g, '\\$&')}/?${color}(.*)${color}\\)`, 'g'); - -function replaceSpecDuration(str) { - return str - .replaceAll(/[0-9.]+ms/g, '*ms') - .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *') - .replace(stackTraceBasePath, '$3'); -} - -function replaceJunitDuration(str) { - return str - .replaceAll(/time="[0-9.]+"/g, 'time="*"') - .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *') - .replaceAll(`hostname="${hostname()}"`, 'hostname="HOSTNAME"') - .replaceAll(/file="[^"]*"/g, 'file="*"') - .replace(stackTraceBasePath, '$3'); -} - -function removeWindowsPathEscaping(str) { - return common.isWindows ? str.replaceAll(/\\\\/g, '\\') : str; -} - -function replaceTestLocationLine(str) { - return str.replaceAll(/(js:)(\d+)(:\d+)/g, '$1(LINE)$3'); -} - -// The Node test coverage returns results for all files called by the test. This -// will make the output file change if files like test/common/index.js change. -// This transform picks only the first line and then the lines from the test -// file. -function pickTestFileFromLcov(str) { - const lines = str.split(/\n/); - const firstLineOfTestFile = lines.findIndex( - (line) => line.startsWith('SF:') && line.trim().endsWith('output.js') - ); - const lastLineOfTestFile = lines.findIndex( - (line, index) => index > firstLineOfTestFile && line.trim() === 'end_of_record' - ); - return ( - lines[0] + '\n' + lines.slice(firstLineOfTestFile, lastLineOfTestFile + 1).join('\n') + '\n' - ); -} - -const defaultTransform = snapshot.transform( - snapshot.replaceWindowsLineEndings, - snapshot.replaceStackTrace, - removeWindowsPathEscaping, - snapshot.transformProjectRoot(), - snapshot.replaceWindowsPaths, - replaceTestDuration, - replaceTestLocationLine, -); -const specTransform = snapshot.transform( - replaceSpecDuration, - snapshot.replaceWindowsLineEndings, - snapshot.replaceStackTrace, - snapshot.replaceWindowsPaths, -); -const junitTransform = snapshot.transform( - replaceJunitDuration, - snapshot.replaceWindowsLineEndings, - snapshot.replaceStackTrace, - snapshot.replaceWindowsPaths, -); -const lcovTransform = snapshot.transform( - snapshot.replaceWindowsLineEndings, - snapshot.replaceStackTrace, - snapshot.transformProjectRoot(), - snapshot.replaceWindowsPaths, - pickTestFileFromLcov -); - - -const tests = [ - { 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', - 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', - flags: ['--test-reporter=tap'], - }, - { - name: 'test-runner/output/test-timeout-flag.js', - flags: [ - '--test-reporter=tap', - '--test-timeout=100', - ], - }, - // --test-timeout should work with or without --test flag - { - name: 'test-runner/output/test-timeout-flag.js', - flags: [ - '--test-reporter=tap', - '--test-timeout=100', - '--test', - ], - }, - { - 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', - 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', - flags: ['--test-reporter=tap'], - }, - process.features.inspector ? - { - name: 'test-runner/output/lcov_reporter.js', - transform: lcovTransform - } : - false, - { 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', - 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/default_output.js', transform: specTransform, tty: true }, - { - name: 'test-runner/output/arbitrary-output.js', - flags: ['--test-reporter=tap'], - }, - { - name: 'test-runner/output/non-tty-forced-color-output.js', - transform: specTransform, - }, - canColorize ? { - name: 'test-runner/output/assertion-color-tty.mjs', - flags: ['--test', '--stack-trace-limit=0'], - transform: specTransform, - tty: true, - } : false, - { - 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 - } : false, - { name: 'test-runner/output/dot_output_custom_columns.js', transform: specTransform, tty: true }, - { - name: 'test-runner/output/tap_escape.js', - transform: snapshot.transform( - 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-watch-spec.mjs', - transform: specTransform, - }, - { - name: 'test-runner/output/test-runner-plan-timeout.js', - flags: ['--test-reporter=tap', '--test-force-exit'], - }, - process.features.inspector ? { - name: 'test-runner/output/coverage_failure.js', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - { - name: 'test-runner/output/test-diagnostic-warning-without-test-only-flag.js', - flags: ['--test', '--test-reporter=tap'], - }, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-40.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-80.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector && !skipCoverageColors ? { - name: 'test-runner/output/coverage-width-80-color.mjs', - flags: ['--test-coverage-exclude=!test/**'], - transform: specTransform, - tty: true - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-100.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-150.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-infinity.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-80-uncovered-lines.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-100-uncovered-lines.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector && !skipCoverageColors ? { - name: 'test-runner/output/coverage-width-80-uncovered-lines-color.mjs', - flags: ['--test-coverage-exclude=!test/**'], - transform: specTransform, - tty: true - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-150-uncovered-lines.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'], - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-short-filename.mjs', - flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'], - cwd: fixtures.path('test-runner/coverage-snap'), - } : false, - process.features.inspector ? { - name: 'test-runner/output/typescript-coverage.mts', - flags: ['--disable-warning=ExperimentalWarning', - '--test-reporter=tap', - '--experimental-transform-types', - '--experimental-test-module-mocks', - '--experimental-test-coverage', - '--test-coverage-exclude=!test/**'] - } : false, - process.features.inspector ? { - name: 'test-runner/output/coverage-with-mock.mjs', - flags: ['--disable-warning=ExperimentalWarning', - '--test-reporter=tap', - '--experimental-transform-types', - '--experimental-test-module-mocks', - '--experimental-test-coverage', - '--test-coverage-exclude=!test/**'] - } : false, -] -.filter(Boolean) -.map(({ flags, name, tty, transform, cwd }) => ({ - name, - fn: common.mustCall(async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags, cwd }); - }), -})); - -if (cwd() !== root) { - chdir(root); -} -describe('test runner output', { concurrency: true }, () => { - for (const { name, fn } of tests) { - it(name, fn); - } -}); diff --git a/test/test-runner/test-output-abort-hooks.mjs b/test/test-runner/test-output-abort-hooks.mjs new file mode 100644 index 00000000000000..2bb1898c5cc7bd --- /dev/null +++ b/test/test-runner/test-output-abort-hooks.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/abort_hooks.js matches test-runner/output/abort_hooks.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/abort_hooks.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-abort-runs-after-hook.mjs b/test/test-runner/test-output-abort-runs-after-hook.mjs new file mode 100644 index 00000000000000..e8716bb08333f7 --- /dev/null +++ b/test/test-runner/test-output-abort-runs-after-hook.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/abort-runs-after-hook.js matches +// test-runner/output/abort-runs-after-hook.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/abort-runs-after-hook.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-abort-suite.mjs b/test/test-runner/test-output-abort-suite.mjs new file mode 100644 index 00000000000000..c3f1b4625b4f5f --- /dev/null +++ b/test/test-runner/test-output-abort-suite.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/abort_suite.js matches test-runner/output/abort_suite.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/abort_suite.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-abort.mjs b/test/test-runner/test-output-abort.mjs new file mode 100644 index 00000000000000..b361bc68035824 --- /dev/null +++ b/test/test-runner/test-output-abort.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/abort.js matches test-runner/output/abort.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/abort.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-arbitrary-output-colored.mjs b/test/test-runner/test-output-arbitrary-output-colored.mjs new file mode 100644 index 00000000000000..77a13d8890430e --- /dev/null +++ b/test/test-runner/test-output-arbitrary-output-colored.mjs @@ -0,0 +1,27 @@ +// Test that the output of test-runner/output/arbitrary-output-colored.js matches +// test-runner/output/arbitrary-output-colored.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { + spawnAndAssert, + specTransform, + replaceTestDuration, + transform, + ensureCwdIsProjectRoot, +} from '../common/assertSnapshot.js'; + +const skipForceColors = + process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' || + process.config.variables.node_shared_openssl; + +if (skipForceColors) { + // https://github.com/nodejs/node/pull/48057 + common.skip('Forced colors not supported in this build'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/arbitrary-output-colored.js'), + transform(specTransform, replaceTestDuration), + { tty: true }, +); diff --git a/test/test-runner/test-output-arbitrary-output.mjs b/test/test-runner/test-output-arbitrary-output.mjs new file mode 100644 index 00000000000000..d7626bb01856fa --- /dev/null +++ b/test/test-runner/test-output-arbitrary-output.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/arbitrary-output.js matches +// test-runner/output/arbitrary-output.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/arbitrary-output.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-assertion-color-tty.mjs b/test/test-runner/test-output-assertion-color-tty.mjs new file mode 100644 index 00000000000000..102b397c815746 --- /dev/null +++ b/test/test-runner/test-output-assertion-color-tty.mjs @@ -0,0 +1,17 @@ +// Flags: --expose-internals +// Test that the output of test-runner/output/assertion-color-tty.mjs matches +// test-runner/output/assertion-color-tty.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, canColorize, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!canColorize()) { + common.skip('TTY colors not supported'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/assertion-color-tty.mjs'), + specTransform, + { flags: ['--test', '--stack-trace-limit=0'], tty: true }, +); diff --git a/test/test-runner/test-output-async-test-scheduling.mjs b/test/test-runner/test-output-async-test-scheduling.mjs new file mode 100644 index 00000000000000..5903619f7e1266 --- /dev/null +++ b/test/test-runner/test-output-async-test-scheduling.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/async-test-scheduling.mjs matches +// test-runner/output/async-test-scheduling.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/async-test-scheduling.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-before-and-after-each-too-many-listeners.mjs b/test/test-runner/test-output-before-and-after-each-too-many-listeners.mjs new file mode 100644 index 00000000000000..bcaec70b17276a --- /dev/null +++ b/test/test-runner/test-output-before-and-after-each-too-many-listeners.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/before-and-after-each-too-many-listeners.js matches +// test-runner/output/before-and-after-each-too-many-listeners.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/before-and-after-each-too-many-listeners.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-before-and-after-each-with-timeout-too-many-listeners.mjs b/test/test-runner/test-output-before-and-after-each-with-timeout-too-many-listeners.mjs new file mode 100644 index 00000000000000..7804692911aeda --- /dev/null +++ b/test/test-runner/test-output-before-and-after-each-with-timeout-too-many-listeners.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js matches +// test-runner/output/before-and-after-each-with-timeout-too-many-listeners.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-coverage-failure.mjs b/test/test-runner/test-output-coverage-failure.mjs new file mode 100644 index 00000000000000..fc171db3ef4627 --- /dev/null +++ b/test/test-runner/test-output-coverage-failure.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage_failure.js matches +// test-runner/output/coverage_failure.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage_failure.js'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-short-filename.mjs b/test/test-runner/test-output-coverage-short-filename.mjs new file mode 100644 index 00000000000000..04d673f530689f --- /dev/null +++ b/test/test-runner/test-output-coverage-short-filename.mjs @@ -0,0 +1,19 @@ +// Test that the output of test-runner/output/coverage-short-filename.mjs matches +// test-runner/output/coverage-short-filename.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-short-filename.mjs'), + defaultTransform, + { + flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'], + cwd: fixtures.path('test-runner/coverage-snap'), + }, +); diff --git a/test/test-runner/test-output-coverage-width-100-uncovered-lines.mjs b/test/test-runner/test-output-coverage-width-100-uncovered-lines.mjs new file mode 100644 index 00000000000000..dd7e1a9c455fbe --- /dev/null +++ b/test/test-runner/test-output-coverage-width-100-uncovered-lines.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-100-uncovered-lines.mjs matches +// test-runner/output/coverage-width-100-uncovered-lines.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-100-uncovered-lines.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-100.mjs b/test/test-runner/test-output-coverage-width-100.mjs new file mode 100644 index 00000000000000..515e1d4e02cac4 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-100.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-100.mjs matches +// test-runner/output/coverage-width-100.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-100.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-150-uncovered-lines.mjs b/test/test-runner/test-output-coverage-width-150-uncovered-lines.mjs new file mode 100644 index 00000000000000..a09aa303c8cc73 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-150-uncovered-lines.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-150-uncovered-lines.mjs matches +// test-runner/output/coverage-width-150-uncovered-lines.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-150-uncovered-lines.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-150.mjs b/test/test-runner/test-output-coverage-width-150.mjs new file mode 100644 index 00000000000000..077483de649f11 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-150.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-150.mjs matches +// test-runner/output/coverage-width-150.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-150.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-40.mjs b/test/test-runner/test-output-coverage-width-40.mjs new file mode 100644 index 00000000000000..2fa862ac48e65b --- /dev/null +++ b/test/test-runner/test-output-coverage-width-40.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-40.mjs matches +// test-runner/output/coverage-width-40.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-40.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-80-color.mjs b/test/test-runner/test-output-coverage-width-80-color.mjs new file mode 100644 index 00000000000000..97d11c2a48a584 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-80-color.mjs @@ -0,0 +1,21 @@ +// Flags: --expose-internals +// Test that the output of test-runner/output/coverage-width-80-color.mjs matches +// test-runner/output/coverage-width-80-color.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, canColorize, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +if (!canColorize()) { + common.skip('TTY colors not supported'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-80-color.mjs'), + specTransform, + { flags: ['--test-coverage-exclude=!test/**'], tty: true }, +); diff --git a/test/test-runner/test-output-coverage-width-80-uncovered-lines-color.mjs b/test/test-runner/test-output-coverage-width-80-uncovered-lines-color.mjs new file mode 100644 index 00000000000000..1b2cb29620d6ff --- /dev/null +++ b/test/test-runner/test-output-coverage-width-80-uncovered-lines-color.mjs @@ -0,0 +1,21 @@ +// Flags: --expose-internals +// Test that the output of test-runner/output/coverage-width-80-uncovered-lines-color.mjs matches +// test-runner/output/coverage-width-80-uncovered-lines-color.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, canColorize, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +if (!canColorize()) { + common.skip('TTY colors not supported'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-80-uncovered-lines-color.mjs'), + specTransform, + { flags: ['--test-coverage-exclude=!test/**'], tty: true }, +); diff --git a/test/test-runner/test-output-coverage-width-80-uncovered-lines.mjs b/test/test-runner/test-output-coverage-width-80-uncovered-lines.mjs new file mode 100644 index 00000000000000..39cc7d9403c96a --- /dev/null +++ b/test/test-runner/test-output-coverage-width-80-uncovered-lines.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-80-uncovered-lines.mjs matches +// test-runner/output/coverage-width-80-uncovered-lines.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-80-uncovered-lines.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-80.mjs b/test/test-runner/test-output-coverage-width-80.mjs new file mode 100644 index 00000000000000..dabf7644726b43 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-80.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-80.mjs matches +// test-runner/output/coverage-width-80.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-80.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-infinity-uncovered-lines.mjs b/test/test-runner/test-output-coverage-width-infinity-uncovered-lines.mjs new file mode 100644 index 00000000000000..b75bec1e04ec37 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-infinity-uncovered-lines.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-infinity-uncovered-lines.mjs matches +// test-runner/output/coverage-width-infinity-uncovered-lines.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-infinity-uncovered-lines.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-width-infinity.mjs b/test/test-runner/test-output-coverage-width-infinity.mjs new file mode 100644 index 00000000000000..f586ff9ab159d0 --- /dev/null +++ b/test/test-runner/test-output-coverage-width-infinity.mjs @@ -0,0 +1,16 @@ +// Test that the output of test-runner/output/coverage-width-infinity.mjs matches +// test-runner/output/coverage-width-infinity.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-width-infinity.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'] }, +); diff --git a/test/test-runner/test-output-coverage-with-mock.mjs b/test/test-runner/test-output-coverage-with-mock.mjs new file mode 100644 index 00000000000000..f489451e184d6d --- /dev/null +++ b/test/test-runner/test-output-coverage-with-mock.mjs @@ -0,0 +1,25 @@ +// Test that the output of test-runner/output/coverage-with-mock.mjs matches +// test-runner/output/coverage-with-mock.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/coverage-with-mock.mjs'), + defaultTransform, + { + flags: [ + '--disable-warning=ExperimentalWarning', + '--test-reporter=tap', + '--experimental-transform-types', + '--experimental-test-module-mocks', + '--experimental-test-coverage', + '--test-coverage-exclude=!test/**', + ], + }, +); diff --git a/test/test-runner/test-output-default-output.mjs b/test/test-runner/test-output-default-output.mjs new file mode 100644 index 00000000000000..96ae139902755e --- /dev/null +++ b/test/test-runner/test-output-default-output.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/default_output.js matches test-runner/output/default_output.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/default_output.js'), + specTransform, + { tty: true }, +); diff --git a/test/test-runner/test-output-describe-it.mjs b/test/test-runner/test-output-describe-it.mjs new file mode 100644 index 00000000000000..219951d5aec75e --- /dev/null +++ b/test/test-runner/test-output-describe-it.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/describe_it.js matches test-runner/output/describe_it.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/describe_it.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-describe-nested.mjs b/test/test-runner/test-output-describe-nested.mjs new file mode 100644 index 00000000000000..661048527fa668 --- /dev/null +++ b/test/test-runner/test-output-describe-nested.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/describe_nested.js matches test-runner/output/describe_nested.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/describe_nested.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-dot-output-custom-columns.mjs b/test/test-runner/test-output-dot-output-custom-columns.mjs new file mode 100644 index 00000000000000..c8061e6ba27e85 --- /dev/null +++ b/test/test-runner/test-output-dot-output-custom-columns.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/dot_output_custom_columns.js matches +// test-runner/output/dot_output_custom_columns.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/dot_output_custom_columns.js'), + specTransform, + { tty: true }, +); diff --git a/test/test-runner/test-output-dot-reporter.mjs b/test/test-runner/test-output-dot-reporter.mjs new file mode 100644 index 00000000000000..46312203bb46d7 --- /dev/null +++ b/test/test-runner/test-output-dot-reporter.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/dot_reporter.js matches test-runner/output/dot_reporter.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/dot_reporter.js'), + specTransform, +); diff --git a/test/test-runner/test-output-eval-dot.mjs b/test/test-runner/test-output-eval-dot.mjs new file mode 100644 index 00000000000000..e31334ac52dd2b --- /dev/null +++ b/test/test-runner/test-output-eval-dot.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/eval_dot.js matches test-runner/output/eval_dot.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/eval_dot.js'), + specTransform, +); diff --git a/test/test-runner/test-output-eval-spec.mjs b/test/test-runner/test-output-eval-spec.mjs new file mode 100644 index 00000000000000..86d6677552bdc5 --- /dev/null +++ b/test/test-runner/test-output-eval-spec.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/eval_spec.js matches test-runner/output/eval_spec.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/eval_spec.js'), + specTransform, +); diff --git a/test/test-runner/test-output-eval-tap.mjs b/test/test-runner/test-output-eval-tap.mjs new file mode 100644 index 00000000000000..a1902ec92878f4 --- /dev/null +++ b/test/test-runner/test-output-eval-tap.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/eval_tap.js matches test-runner/output/eval_tap.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/eval_tap.js'), + defaultTransform, +); diff --git a/test/test-runner/test-output-filtered-suite-delayed-build.mjs b/test/test-runner/test-output-filtered-suite-delayed-build.mjs new file mode 100644 index 00000000000000..c4ec3f3b019731 --- /dev/null +++ b/test/test-runner/test-output-filtered-suite-delayed-build.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/filtered-suite-delayed-build.js matches +// test-runner/output/filtered-suite-delayed-build.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/filtered-suite-delayed-build.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-filtered-suite-order.mjs b/test/test-runner/test-output-filtered-suite-order.mjs new file mode 100644 index 00000000000000..f29c4dcf62bc3f --- /dev/null +++ b/test/test-runner/test-output-filtered-suite-order.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/filtered-suite-order.mjs matches +// test-runner/output/filtered-suite-order.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/filtered-suite-order.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-filtered-suite-throws.mjs b/test/test-runner/test-output-filtered-suite-throws.mjs new file mode 100644 index 00000000000000..7976e3b63753de --- /dev/null +++ b/test/test-runner/test-output-filtered-suite-throws.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/filtered-suite-throws.js matches +// test-runner/output/filtered-suite-throws.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/filtered-suite-throws.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-force-exit.mjs b/test/test-runner/test-output-force-exit.mjs new file mode 100644 index 00000000000000..5138e3df57da31 --- /dev/null +++ b/test/test-runner/test-output-force-exit.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/force_exit.js matches test-runner/output/force_exit.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/force_exit.js'), + specTransform, +); diff --git a/test/test-runner/test-output-global-after-should-fail-the-test.mjs b/test/test-runner/test-output-global-after-should-fail-the-test.mjs new file mode 100644 index 00000000000000..71179d7f15ebfc --- /dev/null +++ b/test/test-runner/test-output-global-after-should-fail-the-test.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/global_after_should_fail_the_test.js matches +// test-runner/output/global_after_should_fail_the_test.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/global_after_should_fail_the_test.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-global-hooks-with-no-tests.mjs b/test/test-runner/test-output-global-hooks-with-no-tests.mjs new file mode 100644 index 00000000000000..361948df103ba2 --- /dev/null +++ b/test/test-runner/test-output-global-hooks-with-no-tests.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/global-hooks-with-no-tests.js matches +// test-runner/output/global-hooks-with-no-tests.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/global-hooks-with-no-tests.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-hooks-spec-reporter.mjs b/test/test-runner/test-output-hooks-spec-reporter.mjs new file mode 100644 index 00000000000000..cc46592fb74c6d --- /dev/null +++ b/test/test-runner/test-output-hooks-spec-reporter.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/hooks_spec_reporter.js matches +// test-runner/output/hooks_spec_reporter.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/hooks_spec_reporter.js'), + specTransform, +); diff --git a/test/test-runner/test-output-hooks-with-no-global-test.mjs b/test/test-runner/test-output-hooks-with-no-global-test.mjs new file mode 100644 index 00000000000000..a0c0327e0f9ec2 --- /dev/null +++ b/test/test-runner/test-output-hooks-with-no-global-test.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/hooks-with-no-global-test.js matches +// test-runner/output/hooks-with-no-global-test.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/hooks-with-no-global-test.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-hooks.mjs b/test/test-runner/test-output-hooks.mjs new file mode 100644 index 00000000000000..b1e1d655df6db8 --- /dev/null +++ b/test/test-runner/test-output-hooks.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/hooks.js matches test-runner/output/hooks.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/hooks.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-junit-reporter.mjs b/test/test-runner/test-output-junit-reporter.mjs new file mode 100644 index 00000000000000..ece14e09ac2e04 --- /dev/null +++ b/test/test-runner/test-output-junit-reporter.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/junit_reporter.js matches +// test-runner/output/junit_reporter.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, junitTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/junit_reporter.js'), + junitTransform, +); diff --git a/test/test-runner/test-output-lcov-reporter.mjs b/test/test-runner/test-output-lcov-reporter.mjs new file mode 100644 index 00000000000000..93aa38fff2bc66 --- /dev/null +++ b/test/test-runner/test-output-lcov-reporter.mjs @@ -0,0 +1,14 @@ +// Test that the output of test-runner/output/lcov_reporter.js matches test-runner/output/lcov_reporter.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, lcovTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/lcov_reporter.js'), + lcovTransform, +); diff --git a/test/test-runner/test-output-name-and-skip-patterns.mjs b/test/test-runner/test-output-name-and-skip-patterns.mjs new file mode 100644 index 00000000000000..875641a28435c4 --- /dev/null +++ b/test/test-runner/test-output-name-and-skip-patterns.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/name_and_skip_patterns.js matches +// test-runner/output/name_and_skip_patterns.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/name_and_skip_patterns.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-name-pattern-with-only.mjs b/test/test-runner/test-output-name-pattern-with-only.mjs new file mode 100644 index 00000000000000..89b94f8a80a031 --- /dev/null +++ b/test/test-runner/test-output-name-pattern-with-only.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/name_pattern_with_only.js matches +// test-runner/output/name_pattern_with_only.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/name_pattern_with_only.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-name-pattern.mjs b/test/test-runner/test-output-name-pattern.mjs new file mode 100644 index 00000000000000..efaef28ed0f0a9 --- /dev/null +++ b/test/test-runner/test-output-name-pattern.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/name_pattern.js matches test-runner/output/name_pattern.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/name_pattern.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-no-refs.mjs b/test/test-runner/test-output-no-refs.mjs new file mode 100644 index 00000000000000..5e2fbab53b2f54 --- /dev/null +++ b/test/test-runner/test-output-no-refs.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/no_refs.js matches test-runner/output/no_refs.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/no_refs.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-no-tests.mjs b/test/test-runner/test-output-no-tests.mjs new file mode 100644 index 00000000000000..0cff4003e7598c --- /dev/null +++ b/test/test-runner/test-output-no-tests.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/no_tests.js matches test-runner/output/no_tests.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/no_tests.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-non-tty-forced-color-output.mjs b/test/test-runner/test-output-non-tty-forced-color-output.mjs new file mode 100644 index 00000000000000..d630c52e293a35 --- /dev/null +++ b/test/test-runner/test-output-non-tty-forced-color-output.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/non-tty-forced-color-output.js matches +// test-runner/output/non-tty-forced-color-output.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/non-tty-forced-color-output.js'), + specTransform, +); diff --git a/test/test-runner/test-output-only-tests.mjs b/test/test-runner/test-output-only-tests.mjs new file mode 100644 index 00000000000000..93a9097bec15dc --- /dev/null +++ b/test/test-runner/test-output-only-tests.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/only_tests.js matches test-runner/output/only_tests.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/only_tests.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-output-cli.mjs b/test/test-runner/test-output-output-cli.mjs new file mode 100644 index 00000000000000..924b6212e2eae8 --- /dev/null +++ b/test/test-runner/test-output-output-cli.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/output_cli.js matches test-runner/output/output_cli.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/output_cli.js'), + defaultTransform, +); diff --git a/test/test-runner/test-output-output.mjs b/test/test-runner/test-output-output.mjs new file mode 100644 index 00000000000000..1eb152324c4063 --- /dev/null +++ b/test/test-runner/test-output-output.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/output.js matches test-runner/output/output.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/output.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-skip-each-hooks.mjs b/test/test-runner/test-output-skip-each-hooks.mjs new file mode 100644 index 00000000000000..a5fb2fb613627b --- /dev/null +++ b/test/test-runner/test-output-skip-each-hooks.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/skip-each-hooks.js matches +// test-runner/output/skip-each-hooks.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/skip-each-hooks.js'), + specTransform, +); diff --git a/test/test-runner/test-output-skip-pattern.mjs b/test/test-runner/test-output-skip-pattern.mjs new file mode 100644 index 00000000000000..852b48e7a2b6a1 --- /dev/null +++ b/test/test-runner/test-output-skip-pattern.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/skip_pattern.js matches test-runner/output/skip_pattern.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/skip_pattern.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-source-mapped-locations.mjs b/test/test-runner/test-output-source-mapped-locations.mjs new file mode 100644 index 00000000000000..a24bed052dc3ad --- /dev/null +++ b/test/test-runner/test-output-source-mapped-locations.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/source_mapped_locations.mjs matches +// test-runner/output/source_mapped_locations.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/source_mapped_locations.mjs'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-spec-reporter-cli.mjs b/test/test-runner/test-output-spec-reporter-cli.mjs new file mode 100644 index 00000000000000..5b44483601c3a5 --- /dev/null +++ b/test/test-runner/test-output-spec-reporter-cli.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/spec_reporter_cli.js matches +// test-runner/output/spec_reporter_cli.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/spec_reporter_cli.js'), + specTransform, +); diff --git a/test/test-runner/test-output-spec-reporter-successful.mjs b/test/test-runner/test-output-spec-reporter-successful.mjs new file mode 100644 index 00000000000000..0308d1e1f01b24 --- /dev/null +++ b/test/test-runner/test-output-spec-reporter-successful.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/spec_reporter_successful.js matches +// test-runner/output/spec_reporter_successful.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/spec_reporter_successful.js'), + specTransform, +); diff --git a/test/test-runner/test-output-spec-reporter.mjs b/test/test-runner/test-output-spec-reporter.mjs new file mode 100644 index 00000000000000..e7233b13da95d1 --- /dev/null +++ b/test/test-runner/test-output-spec-reporter.mjs @@ -0,0 +1,10 @@ +// Test that the output of test-runner/output/spec_reporter.js matches test-runner/output/spec_reporter.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/spec_reporter.js'), + specTransform, +); diff --git a/test/test-runner/test-output-suite-skip-hooks.mjs b/test/test-runner/test-output-suite-skip-hooks.mjs new file mode 100644 index 00000000000000..183c4bb27c5d34 --- /dev/null +++ b/test/test-runner/test-output-suite-skip-hooks.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/suite-skip-hooks.js matches +// test-runner/output/suite-skip-hooks.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/suite-skip-hooks.js'), + specTransform, +); diff --git a/test/test-runner/test-output-tap-escape.mjs b/test/test-runner/test-output-tap-escape.mjs new file mode 100644 index 00000000000000..f0b4471d5158bb --- /dev/null +++ b/test/test-runner/test-output-tap-escape.mjs @@ -0,0 +1,17 @@ +// Test that the output of test-runner/output/tap_escape.js matches test-runner/output/tap_escape.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { + spawnAndAssert, + transform, + replaceWindowsLineEndings, + replaceTestDuration, + ensureCwdIsProjectRoot, +} from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/tap_escape.js'), + transform(replaceWindowsLineEndings, replaceTestDuration), + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-test-diagnostic-warning-without-test-only-flag.mjs b/test/test-runner/test-output-test-diagnostic-warning-without-test-only-flag.mjs new file mode 100644 index 00000000000000..b5f59df53b867d --- /dev/null +++ b/test/test-runner/test-output-test-diagnostic-warning-without-test-only-flag.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/test-diagnostic-warning-without-test-only-flag.js matches +// test-runner/output/test-diagnostic-warning-without-test-only-flag.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-diagnostic-warning-without-test-only-flag.js'), + defaultTransform, + { flags: ['--test', '--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-test-runner-plan-timeout.mjs b/test/test-runner/test-output-test-runner-plan-timeout.mjs new file mode 100644 index 00000000000000..6771468d3b9fa9 --- /dev/null +++ b/test/test-runner/test-output-test-runner-plan-timeout.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/test-runner-plan-timeout.js matches +// test-runner/output/test-runner-plan-timeout.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-runner-plan-timeout.js'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-force-exit'] }, +); diff --git a/test/test-runner/test-output-test-runner-plan.mjs b/test/test-runner/test-output-test-runner-plan.mjs new file mode 100644 index 00000000000000..a4533e9a1b1196 --- /dev/null +++ b/test/test-runner/test-output-test-runner-plan.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/test-runner-plan.js matches +// test-runner/output/test-runner-plan.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-runner-plan.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-test-runner-watch-spec.mjs b/test/test-runner/test-output-test-runner-watch-spec.mjs new file mode 100644 index 00000000000000..c835b11527a8f0 --- /dev/null +++ b/test/test-runner/test-output-test-runner-watch-spec.mjs @@ -0,0 +1,11 @@ +// Test that the output of test-runner/output/test-runner-watch-spec.mjs matches +// test-runner/output/test-runner-watch-spec.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, specTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-runner-watch-spec.mjs'), + specTransform, +); diff --git a/test/test-runner/test-output-test-timeout-flag-with-test.mjs b/test/test-runner/test-output-test-timeout-flag-with-test.mjs new file mode 100644 index 00000000000000..f34db67d0be2c0 --- /dev/null +++ b/test/test-runner/test-output-test-timeout-flag-with-test.mjs @@ -0,0 +1,13 @@ +// Test that the output of test-runner/output/test-timeout-flag.js matches +// test-runner/output/test-timeout-flag.snapshot with --test flag. +// --test-timeout should work with or without --test flag. +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-timeout-flag.js'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-timeout=100', '--test'] }, +); diff --git a/test/test-runner/test-output-test-timeout-flag.mjs b/test/test-runner/test-output-test-timeout-flag.mjs new file mode 100644 index 00000000000000..96ef6c47af00aa --- /dev/null +++ b/test/test-runner/test-output-test-timeout-flag.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/test-timeout-flag.js matches +// test-runner/output/test-timeout-flag.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/test-timeout-flag.js'), + defaultTransform, + { flags: ['--test-reporter=tap', '--test-timeout=100'] }, +); diff --git a/test/test-runner/test-output-timeout-in-before-each.mjs b/test/test-runner/test-output-timeout-in-before-each.mjs new file mode 100644 index 00000000000000..e0efd67155f556 --- /dev/null +++ b/test/test-runner/test-output-timeout-in-before-each.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js matches +// test-runner/output/timeout_in_before_each_should_not_affect_further_tests.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/timeout_in_before_each_should_not_affect_further_tests.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-output-typescript-coverage.mjs b/test/test-runner/test-output-typescript-coverage.mjs new file mode 100644 index 00000000000000..41aa97d194cc20 --- /dev/null +++ b/test/test-runner/test-output-typescript-coverage.mjs @@ -0,0 +1,25 @@ +// Test that the output of test-runner/output/typescript-coverage.mts matches +// test-runner/output/typescript-coverage.snapshot +import * as common from '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +if (!process.features.inspector) { + common.skip('inspector support required'); +} + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/typescript-coverage.mts'), + defaultTransform, + { + flags: [ + '--disable-warning=ExperimentalWarning', + '--test-reporter=tap', + '--experimental-transform-types', + '--experimental-test-module-mocks', + '--experimental-test-coverage', + '--test-coverage-exclude=!test/**', + ], + }, +); diff --git a/test/test-runner/test-output-unfinished-suite-async-error.mjs b/test/test-runner/test-output-unfinished-suite-async-error.mjs new file mode 100644 index 00000000000000..b6af0ae9a1170f --- /dev/null +++ b/test/test-runner/test-output-unfinished-suite-async-error.mjs @@ -0,0 +1,12 @@ +// Test that the output of test-runner/output/unfinished-suite-async-error.js matches +// test-runner/output/unfinished-suite-async-error.snapshot +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; + +ensureCwdIsProjectRoot(); +await spawnAndAssert( + fixtures.path('test-runner/output/unfinished-suite-async-error.js'), + defaultTransform, + { flags: ['--test-reporter=tap'] }, +); diff --git a/test/test-runner/test-runner.status b/test/test-runner/test-runner.status new file mode 100644 index 00000000000000..65ae96eb9e3726 --- /dev/null +++ b/test/test-runner/test-runner.status @@ -0,0 +1,7 @@ +prefix test-runner + +# To mark a test as flaky, list the test name in the appropriate section +# below, without ".js", followed by ": PASS,FLAKY". Example: +# sample-test : PASS,FLAKY + +[true] # This section applies to all platforms diff --git a/test/test-runner/testcfg.py b/test/test-runner/testcfg.py new file mode 100644 index 00000000000000..fa53433d0dd1e5 --- /dev/null +++ b/test/test-runner/testcfg.py @@ -0,0 +1,6 @@ +import sys, os +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import testpy + +def GetConfiguration(context, root): + return testpy.ParallelTestConfiguration(context, root, 'test-runner')