diff --git a/lib/internal/main/test_runner.js b/lib/internal/main/test_runner.js index a42c1e5dff64cc..9785a74cd1a665 100644 --- a/lib/internal/main/test_runner.js +++ b/lib/internal/main/test_runner.js @@ -22,32 +22,18 @@ let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => { prepareMainThreadExecution(false); markBootstrapComplete(); -const { - perFileTimeout, - runnerConcurrency, - shard, - watchMode, -} = parseCommandLine(); - -let concurrency = runnerConcurrency; -let inspectPort; +const options = parseCommandLine(); if (isUsingInspector()) { process.emitWarning('Using the inspector with --test forces running at a concurrency of 1. ' + 'Use the inspectPort option to run with concurrency'); - concurrency = 1; - inspectPort = process.debugPort; + options.concurrency = 1; + options.inspectPort = process.debugPort; } -const options = { - concurrency, - inspectPort, - watch: watchMode, - setup: setupTestReporters, - timeout: perFileTimeout, - shard, - globPatterns: ArrayPrototypeSlice(process.argv, 1), -}; +options.setup = setupTestReporters; +options.globPatterns = ArrayPrototypeSlice(process.argv, 1); + debug('test runner configuration:', options); run(options).on('test:fail', (data) => { if (data.todo === undefined || data.todo === false) { diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 00922c7b529272..ab41a93fc081f9 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -84,7 +84,7 @@ const { sourceMaps, testNamePatterns, testSkipPatterns, - testOnlyFlag, + only: testOnlyFlag, updateSnapshots, } = parseCommandLine(); let kResistStopPropagation; diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index aae2a756800a0f..bbd69aa4211415 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -197,19 +197,19 @@ function parseCommandLine() { const forceExit = getOptionValue('--test-force-exit'); const sourceMaps = getOptionValue('--enable-source-maps'); const updateSnapshots = getOptionValue('--test-update-snapshots'); - const watchMode = getOptionValue('--watch'); + const watch = getOptionValue('--watch'); const isChildProcess = process.env.NODE_TEST_CONTEXT === 'child'; const isChildProcessV8 = process.env.NODE_TEST_CONTEXT === 'child-v8'; + let concurrency; let coverageExcludeGlobs; let coverageIncludeGlobs; let destinations; - let perFileTimeout; + let only; let reporters; - let runnerConcurrency; + let shard; let testNamePatterns; let testSkipPatterns; - let testOnlyFlag; - let shard; + let timeout; if (isChildProcessV8) { kBuiltinReporters.set('v8-serializer', 'internal/test_runner/reporter/v8-serializer'); @@ -239,9 +239,9 @@ function parseCommandLine() { } if (isTestRunner) { - perFileTimeout = getOptionValue('--test-timeout') || Infinity; - runnerConcurrency = getOptionValue('--test-concurrency') || true; - testOnlyFlag = false; + timeout = getOptionValue('--test-timeout') || Infinity; + concurrency = getOptionValue('--test-concurrency') || true; + only = false; testNamePatterns = null; const shardOption = getOptionValue('--test-shard'); @@ -262,10 +262,10 @@ function parseCommandLine() { }; } } else { - perFileTimeout = Infinity; - runnerConcurrency = 1; + timeout = Infinity; + concurrency = 1; const testNamePatternFlag = getOptionValue('--test-name-pattern'); - testOnlyFlag = getOptionValue('--test-only'); + only = getOptionValue('--test-only'); testNamePatterns = testNamePatternFlag?.length > 0 ? ArrayPrototypeMap( testNamePatternFlag, @@ -284,21 +284,21 @@ function parseCommandLine() { globalTestOptions = { __proto__: null, isTestRunner, + concurrency, coverage, coverageExcludeGlobs, coverageIncludeGlobs, + destinations, forceExit, - perFileTimeout, - runnerConcurrency, + only, + reporters, shard, sourceMaps, - testOnlyFlag, testNamePatterns, testSkipPatterns, + timeout, updateSnapshots, - reporters, - destinations, - watchMode, + watch, }; return globalTestOptions;