Skip to content

feat(testing)!: remove deprecated skipSetupFile and setupFile jest options#35588

Draft
leosvelperez wants to merge 2 commits intomasterfrom
nxc-3672
Draft

feat(testing)!: remove deprecated skipSetupFile and setupFile jest options#35588
leosvelperez wants to merge 2 commits intomasterfrom
nxc-3672

Conversation

@leosvelperez
Copy link
Copy Markdown
Member

Current Behavior

The @nx/jest:jest executor accepts a setupFile option that has been deprecated in favor of declaring setup files via setupFilesAfterEnv in the Jest configuration file. The executor merges setupFile into setupFilesAfterEnv at runtime.

The @nx/jest:configuration generator accepts a skipSetupFile option that has been deprecated in favor of setupFile: 'none'.

Expected Behavior

The @nx/jest:jest executor's setupFile option is removed. The @nx/jest:configuration generator's skipSetupFile option is removed.

Two migrations run automatically on nx migrate.

migrate-jest-executor-setup-file pushes existing executor setupFile values into setupFilesAfterEnv in the project's Jest config (using <rootDir>/... form), then strips the option from project.json and nx.json target defaults. Coverage:

  • Per-target setupFile in project.json (base options or configurations).
  • setupFile in nx.json targetDefaults, including for targets that inherit the default without declaring their own — the migration walks affected projects, expands {projectRoot} per project, and writes the inherited value into each project's Jest config before stripping the default.
  • Configurations that override jestConfig and inherit the base setupFile get their override Jest config migrated too, so nx test <project> -c <config> keeps loading the setup file post-migration.
  • Configurations with their own jestConfig and a different setupFile from base are auto-migrated to the configuration's own Jest config.
  • Static module.exports = {...} and export default {...} shapes, including configs with spreads ({ ...preset } — multi-spread mirrors object-spread "last wins" via a nullish-coalescing fallback chain) and quoted property names.
  • Custom rootDir declared as a string literal — the migrated path is computed relative to the resolved rootDir.
  • Path-aware deduplication: existing './src/setup.ts' entries aren't duplicated when the new entry resolves to the same file.

Edge cases that can't safely be auto-rewritten still strip the dead option but surface a follow-up warning listing the affected targets so the setup file path can be moved manually:

  • Non-static configs (factory functions, dynamic exports) → unparseable.
  • Custom rootDir declared as a non-literal expression → nonLiteralRootDir.
  • Shared Jest config across targets with different setup files → sharedConfigConflict.
  • setupFile plus setupFilesAfterEnv passthrough in the same scope → passthroughCollision.
  • Configuration-scoped setupFile that would leak to the base run → configurationOnly.
  • Targets without any resolvable jestConfignoResolvableJestConfig.

migrate-jest-configuration-skip-setup-file rewrites skipSetupFile defaults stored in nx.json generators or per-project project.json generators (both flat @nx/jest:configuration and nested @nx/jestconfiguration forms): skipSetupFile: true becomes setupFile: 'none' (preserving original behavior), skipSetupFile: false is dropped (it was a no-op). CLI invocations of @nx/jest:configuration --skipSetupFile should pass --setupFile=none instead.

BREAKING CHANGE: The setupFile option of the @nx/jest:jest executor and the skipSetupFile option of the @nx/jest:configuration generator are removed.

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

netlify Bot commented May 6, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit eb32659
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69fb45fa01feeb0008cb66ed
😎 Deploy Preview https://deploy-preview-35588--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
Copy Markdown

netlify Bot commented May 6, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit eb32659
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69fb45fbcb6b890008c6181a
😎 Deploy Preview https://deploy-preview-35588--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
Copy Markdown
Contributor

nx-cloud Bot commented May 6, 2026

View your CI Pipeline Execution ↗ for commit eb32659

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ⛔ Cancelled 4m 28s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 17s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 7s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-06 14:53:07 UTC

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.

1 participant