Skip to content

fix(testing): infer task inputs from jest config file references#34740

Open
leosvelperez wants to merge 4 commits intomasterfrom
nxc-4005
Open

fix(testing): infer task inputs from jest config file references#34740
leosvelperez wants to merge 4 commits intomasterfrom
nxc-4005

Conversation

@leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Mar 6, 2026

Current Behavior

The Jest plugin infers test target inputs from the preset file path but ignores other config properties that reference files — transforms, setup files, module name mappers, reporters, watch plugins, etc. Changes to those files don't invalidate the test cache.

Expected Behavior

All Jest config properties that reference files are resolved and included as task inputs, matching Jest's merge semantics:

  • Replaced (config wins over preset): resolver, globalSetup, globalTeardown, snapshotResolver, snapshotSerializers, testResultsProcessor, runner, reporters, watchPlugins
  • Concatenated (preset + config): setupFiles, setupFilesAfterEnv
  • Deep merged (config keys win): moduleNameMapper, transform

Also handles jest-runner-/jest-watch- prefix resolution, <rootDir> in preset values, and Windows path normalization.

Adds a useJestResolver option to control whether jest-resolve is used for input resolution, decoupled from disableJestRuntime. By default, inputs are resolved using path-based classification (fast, no filesystem calls beyond what's already done). When useJestResolver is enabled, jest-resolve is used instead, which follows symlinks and honors custom moduleDirectories/modulePaths — more accurate for workspace-linked packages but slower due to filesystem probing per resolved path.

@leosvelperez leosvelperez self-assigned this Mar 6, 2026
@netlify
Copy link

netlify bot commented Mar 6, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 0503e01
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69b42159bd694b0008a7af94
😎 Deploy Preview https://deploy-preview-34740--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 6, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 0503e01
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69b4215941b4ca0007541933
😎 Deploy Preview https://deploy-preview-34740--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 6, 2026

View your CI Pipeline Execution ↗ for commit 0503e01

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1h 3m 23s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 27s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-13 15:46:23 UTC

nx-cloud[bot]

This comment was marked as outdated.

@leosvelperez leosvelperez changed the title fix(core): add missing test target inputs for jest preset scripts fix(testing): infer task inputs from jest config file references Mar 11, 2026
@leosvelperez leosvelperez requested a review from a team as a code owner March 11, 2026 12:15
@leosvelperez leosvelperez force-pushed the nxc-4005 branch 3 times, most recently from 288eee6 to 0dd3bf1 Compare March 13, 2026 11:10
Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We determined this CI failure is unrelated to our changes. The maven-batch-runner:package task fails due to a missing target/generated-sources/annotations directory in the maven4-adapter module — a pre-existing build infrastructure issue where the annotation processor is not generating the expected sources. Our PR only touches the Jest plugin and documentation, so this failure requires an environment-level fix independent of this PR.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

leosvelperez and others added 3 commits March 13, 2026 15:27
Resolve all Jest config properties that reference files as task inputs,
matching Jest's actual merge semantics (replaced, concatenated, deep
merged). Handle runner `jest-runner-` and watchPlugins `jest-watch-`
prefix resolution. Normalize Windows paths in resolved inputs.

Add a `useJestResolver` option to control whether jest-resolve is used
for input resolution, decoupled from `disableJestRuntime`.
…vedPath

Fixes false positive when directory names start with 'node_modules'
but aren't actual node_modules directories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants