feat(testing)!: remove deprecated skipSetupFile and setupFile jest options#35588
Draft
leosvelperez wants to merge 2 commits intomasterfrom
Draft
feat(testing)!: remove deprecated skipSetupFile and setupFile jest options#35588leosvelperez wants to merge 2 commits intomasterfrom
leosvelperez wants to merge 2 commits intomasterfrom
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit eb32659
☁️ Nx Cloud last updated this comment at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
The
@nx/jest:jestexecutor accepts asetupFileoption that has been deprecated in favor of declaring setup files viasetupFilesAfterEnvin the Jest configuration file. The executor mergessetupFileintosetupFilesAfterEnvat runtime.The
@nx/jest:configurationgenerator accepts askipSetupFileoption that has been deprecated in favor ofsetupFile: 'none'.Expected Behavior
The
@nx/jest:jestexecutor'ssetupFileoption is removed. The@nx/jest:configurationgenerator'sskipSetupFileoption is removed.Two migrations run automatically on
nx migrate.migrate-jest-executor-setup-filepushes existing executorsetupFilevalues intosetupFilesAfterEnvin the project's Jest config (using<rootDir>/...form), then strips the option fromproject.jsonandnx.jsontarget defaults. Coverage:setupFileinproject.json(base options or configurations).setupFileinnx.jsontargetDefaults, 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.jestConfigand inherit the basesetupFileget their override Jest config migrated too, sonx test <project> -c <config>keeps loading the setup file post-migration.jestConfigand a differentsetupFilefrom base are auto-migrated to the configuration's own Jest config.module.exports = {...}andexport default {...}shapes, including configs with spreads ({ ...preset }— multi-spread mirrors object-spread "last wins" via a nullish-coalescing fallback chain) and quoted property names.rootDirdeclared as a string literal — the migrated path is computed relative to the resolvedrootDir.'./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:
unparseable.rootDirdeclared as a non-literal expression →nonLiteralRootDir.sharedConfigConflict.setupFileplussetupFilesAfterEnvpassthrough in the same scope →passthroughCollision.setupFilethat would leak to the base run →configurationOnly.jestConfig→noResolvableJestConfig.migrate-jest-configuration-skip-setup-filerewritesskipSetupFiledefaults stored innx.jsongeneratorsor per-projectproject.jsongenerators(both flat@nx/jest:configurationand nested@nx/jest→configurationforms):skipSetupFile: truebecomessetupFile: 'none'(preserving original behavior),skipSetupFile: falseis dropped (it was a no-op). CLI invocations of@nx/jest:configuration --skipSetupFileshould pass--setupFile=noneinstead.BREAKING CHANGE: The
setupFileoption of the@nx/jest:jestexecutor and theskipSetupFileoption of the@nx/jest:configurationgenerator are removed.