Skip to content

Commit

Permalink
feat: add sourceMaps option
Browse files Browse the repository at this point in the history
When this option is false, the --enable-source-maps Node.js flag is not set for worker threads.
  • Loading branch information
aleclarson committed Aug 13, 2023
1 parent e58f466 commit 3352b69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const FLAGS = {
description: 'Run tests serially',
type: 'boolean',
},
'source-maps': {
coerce: coerceLastValue,
description: 'Enable source maps support (true by default)',
type: 'boolean',
},
tap: {
alias: 't',
coerce: coerceLastValue,
Expand Down Expand Up @@ -228,6 +233,8 @@ export default async function loadCli() { // eslint-disable-line complexity
combined.failFast = argv[flag];
} else if (flag === 'update-snapshots') {
combined.updateSnapshots = argv[flag];
} else if (flag === 'source-maps') {
combined.sourceMaps = argv[flag];

Check warning on line 237 in lib/cli.js

View check run for this annotation

Codecov / codecov/patch

lib/cli.js#L237

Added line #L237 was not covered by tests
} else if (flag !== 'node-arguments') {
combined[flag] = argv[flag];
}
Expand Down Expand Up @@ -429,6 +436,7 @@ export default async function loadCli() { // eslint-disable-line complexity
nodeArguments,
parallelRuns,
sortTestFiles: conf.sortTestFiles,
sourceMaps: combined.sourceMaps,
projectDir,
providers,
ranFromCli: true,
Expand Down
11 changes: 7 additions & 4 deletions lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ export function _testOnlyReplaceWorkerPath(replacement) {
workerPath = replacement;
}

const additionalExecArgv = ['--enable-source-maps'];

const createWorker = (options, execArgv) => {
let worker;
let postMessage;
let close;

if (options.sourceMaps !== false) {
execArgv = [...execArgv, '--enable-source-maps'];
}

if (options.workerThreads) {
worker = new Worker(workerPath, {
argv: options.workerArgv,
env: {NODE_ENV: 'test', ...process.env, ...options.environmentVariables},
execArgv: [...execArgv, ...additionalExecArgv],
execArgv,
workerData: {
options,
},
Expand All @@ -46,7 +49,7 @@ const createWorker = (options, execArgv) => {
cwd: options.projectDir,
silent: true,
env: {NODE_ENV: 'test', ...process.env, ...options.environmentVariables},
execArgv: [...execArgv, ...additionalExecArgv],
execArgv,
serialization: 'advanced',
});
postMessage = controlFlow(worker);
Expand Down

0 comments on commit 3352b69

Please sign in to comment.