From f898ea7963af2d64b9fe26ba416da6cb945342e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Wed, 23 Mar 2022 22:17:32 -0400 Subject: [PATCH] fix: allow usage of ts-node in sub-processes (#20762) --- .../data-context/src/data/ProjectLifecycleManager.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 49f9b551fa..c451356f43 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -1001,15 +1001,17 @@ export class ProjectLifecycleManager { private forkConfigProcess () { const configProcessArgs = ['--projectRoot', this.projectRoot, '--file', this.configFilePath] + // allow the use of ts-node in subprocesses tests by removing the env constant from it + // without this line, packages/ts/register.js never registers the ts-node module for config and + // run_plugins can't use the config module. + const { CYPRESS_INTERNAL_E2E_TESTING_SELF, ...env } = process.env + + env.NODE_OPTIONS = process.env.ORIGINAL_NODE_OPTIONS || '' const childOptions: ForkOptions = { stdio: 'pipe', cwd: path.dirname(this.configFilePath), - env: { - ...process.env, - NODE_OPTIONS: process.env.ORIGINAL_NODE_OPTIONS || '', - // DEBUG: '*', - }, + env, execPath: this.ctx.nodePath ?? undefined, }