From 4bf2984d6d1e57a56cdbf54f6e7c7ad562ccc7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 4 Dec 2024 12:12:02 +0100 Subject: [PATCH] fix(testing): force compatible module resolution when running the jest executor --- packages/jest/src/executors/jest/jest.impl.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/jest/src/executors/jest/jest.impl.ts b/packages/jest/src/executors/jest/jest.impl.ts index 2c8210d5cb89f..57a045a053584 100644 --- a/packages/jest/src/executors/jest/jest.impl.ts +++ b/packages/jest/src/executors/jest/jest.impl.ts @@ -21,6 +21,10 @@ export async function jestExecutor( options: JestExecutorOptions, context: ExecutorContext ): Promise<{ success: boolean }> { + // Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119 + // We want to support of ESM via 'module':'nodenext', we need to override the resolution until Jest supports it. + process.env.TS_NODE_COMPILER_OPTIONS ??= '{"moduleResolution":"node10"}'; + const config = await jestConfigParser(options, context); const { results } = await runCLI(config, [options.jestConfig]);