Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/internal/main/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ if (isUsingInspector() && options.isolation === 'process') {
}

options.globPatterns = ArrayPrototypeSlice(process.argv, 1);
options.env = process.env;
options.cwd = process.cwd();

debug('test runner configuration:', options);
run(options).on('test:summary', (data) => {
Expand Down
11 changes: 6 additions & 5 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ function getRunArgs(path, { forceExit,
* An example of such option are --allow-natives-syntax and --expose-gc
*/
const nodeOptionsSet = new SafeSet(processNodeOptions);
const sourceExecArgv = execArgv.length > 0 ? execArgv : process.execArgv;
const unknownProcessExecArgv = ArrayPrototypeFilter(
process.execArgv,
sourceExecArgv,
(arg, i, arr) => !nodeOptionsSet.has(arg) && filterExecArgv(arg, i, arr),
);
ArrayPrototypePushApply(runArgs, unknownProcessExecArgv);
Expand Down Expand Up @@ -500,7 +501,7 @@ function runTestFile(path, filesWatcher, opts) {
const subtest = opts.root.createSubtest(FileTest, testPath, testOpts, async (t) => {
const args = getRunArgs(path, opts);
const stdio = ['pipe', 'pipe', 'pipe'];
const env = { __proto__: null, NODE_TEST_CONTEXT: 'child-v8', ...(opts.env || process.env) };
const env = { __proto__: null, NODE_TEST_CONTEXT: 'child-v8', ...(opts.env ?? {}) };

// Acquire a worker ID from the pool for process isolation mode
let workerId;
Expand Down Expand Up @@ -732,7 +733,7 @@ function run(options = kEmptyObject) {
argv = [],
cwd = process.cwd(),
rerunFailuresFilePath,
env,
env = process.env,
} = options;

if (files != null) {
Expand Down Expand Up @@ -907,7 +908,7 @@ function run(options = kEmptyObject) {
validatePath(globalSetupPath, 'options.globalSetupPath');
}

if (env != null) {
if ('env' in options) {
validateObject(env);

if (isolation === 'none') {
Expand Down Expand Up @@ -997,7 +998,7 @@ function run(options = kEmptyObject) {
};

if (isolation === 'process') {
if (process.env.NODE_TEST_CONTEXT !== undefined) {
if ((env?.NODE_TEST_CONTEXT ?? process.env.NODE_TEST_CONTEXT) !== undefined) {
process.emitWarning('node:test run() is being called recursively within a test file. skipping running files.');
root.postRun();
return root.reporter;
Expand Down