Skip to content

Commit

Permalink
test_runner: separate option validation logic from run function
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarchini committed Dec 2, 2024
1 parent 61e4ad5 commit 4f3b8ad
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function watchFiles(testFiles, opts) {
return filesWatcher;
}

function run(options = kEmptyObject) {
function validateAndSetDefaultOptions(options) {
validateObject(options, 'options');

let {
Expand Down Expand Up @@ -664,6 +664,61 @@ function run(options = kEmptyObject) {
validateStringArray(argv, 'options.argv');
validateStringArray(execArgv, 'options.execArgv');

return {
__proto__: null,
testNamePatterns,
testSkipPatterns,
shard,
coverageExcludeGlobs,
coverageIncludeGlobs,
concurrency,
timeout,
signal,
files,
forceExit,
inspectPort,
isolation,
watch,
setup,
only,
globPatterns,
coverage,
lineCoverage,
branchCoverage,
functionCoverage,
execArgv,
argv,
cwd,
};
}

function run(options = kEmptyObject) {
const {
testNamePatterns,
testSkipPatterns,
shard,
coverageExcludeGlobs,
coverageIncludeGlobs,
concurrency,
timeout,
signal,
files,
forceExit,
inspectPort,
isolation,
watch,
setup,
only,
globPatterns,
coverage,
lineCoverage,
branchCoverage,
functionCoverage,
execArgv,
argv,
cwd,
} = validateAndSetDefaultOptions(options);

const rootTestOptions = { __proto__: null, concurrency, timeout, signal };
const globalOptions = {
__proto__: null,
Expand Down

0 comments on commit 4f3b8ad

Please sign in to comment.