Skip to content

Commit

Permalink
fix(testing): force compatible module resolution when running the jes…
Browse files Browse the repository at this point in the history
…t executor (#29189)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #29139
  • Loading branch information
leosvelperez authored Dec 4, 2024
1 parent aefafc5 commit 59e3704
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/jest/src/executors/jest/jest.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 59e3704

Please sign in to comment.