Upgrading babel-jest 27 to 28
Breaking27.5.1 → 28.1.3Breaking50Platform4Deprecated1New36Changed22Fixed44Other17
BreakingUpgrade verdict
48 breaking changes and 4 platform requirement changes.
In plain terms
- The testURL setting is gone; set the URL under testEnvironmentOptions instead.
- You must now install jest-environment-jsdom yourself to use the jsdom environment.
- You must now install jest-jasmine2 yourself to use the jasmine2 test runner.
- The moduleLoader setting is now called runtime.
Must act Top 5 of 53 that need code or config changes
Node.js requirement changed in 28.0.2: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0 → ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0.
Drops @jest/types.
Installs 140 packages in all (was 142).
What you must change
Breaking48
Removes the
testURL config option in favor of testEnvironmentOptions.url.testURLtestEnvironmentOptions.urlStops shipping
jest-environment-jsdom by default.jest-environment-jsdomStops shipping
jest-jasmine2 by default.jest-jasmine2Renames the
moduleLoader config option to runtime.moduleLoaderruntimeRenames the
extraGlobals config option to sandboxInjectedGlobals.extraGlobalssandboxInjectedGlobalsAdds default
browser condition to exportConditions for the jsdom environment.jest-environment-jsdomexportConditionsbrowserAdds default
node and node-addon conditions to exportConditions for the node environment.jest-environment-nodeexportConditionsnodenode-addonRenames the
timers configuration option to fakeTimers.@jest/fake-timerstimersfakeTimersRenames exported utility types and removes
ArgumentsOf, ArgsType, ConstructorArgumentsOf in favor of TS builtins.ClassLikeFunctionLikeConstructorLikeKeysMethodLikeKeysPropertyLikeKeysArgumentsOfArgsTypeConstructorArgumentsOfRemoves browser option from resolver options; use conditions: ['browser'] instead.
browserconditionsjest-worker defaults to advanced serialization when using child process workers.
jest-workerAdds mjs and cjs to the default moduleFileExtensions config.
moduleFileExtensionsmjscjsexpect no longer supports importing build/utils.
build/utilsjest-config removes the getTestEnvironment export.
getTestEnvironmentjest-config renames the config option name to id.
nameidRemoves
Config.Glob and Config.Path from jest-types.Config.GlobConfig.PathDefaults
jest-haste-map to the node crawler instead of shelling out to find when watchman is not enabled.jest-haste-mapwatchmanRemoves the undocumented
--timers CLI option.--timersThrows an error instead of a warning when multiple configs are used.
Stops normalizing long deprecated options
preprocessorIgnorePatterns, scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs.preprocessorIgnorePatternsscriptPreprocessorsetupTestFrameworkScriptFiletestPathDirsMoves the
TestWatcher class to the jest-watcher package.TestWatcherjest-watcherUpgrades jsdom to 19.0.0 in jest-environment-jsdom.
jest-environment-jsdomPasses global config to the Jest environment constructor for the
jsdom environment.jest-environment-jsdomjest-environment-nodeMakes the second constructor argument
context mandatory for the jsdom environment.jest-environment-jsdomcontextjest-environment-nodeAllows
jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag.jest.useFakeTimers()projectConfig.fakeTimersHasteMap.create now returns a promise.HasteMap.createImproves the usage of the
jest.fn generic type argument.jest.fnAdds support for package.json exports in jest-resolve.
jest-resolvepackage.jsonexportsRuntime.createHasteMap now returns a promise.
Runtime.createHasteMapRemoves Context type export from jest-runtime; import it from @jest/test-result instead.
Context@jest/test-resultRequires process() and processAsync() methods to always return structured data.
process()processAsync()PatternPrompt now takes entityName as third constructor parameter instead of this._entityName.
PatternPromptentityNamethis._entityNameAllows only absolute workerPath in jest-worker.
workerPathbabel-jest passes rootDir as root in Babel's options.
babel-jestrootDirrootFixes false positives when looking for an undefined prop in @jest/expect-utils.
@jest/expect-utilsMoves all jasmine specific types from @jest/types to its own package.
@jest/typesjest-jasmine2jest-typesbabel-jest now only exports createTransformer.
createTransformerexpect migrates to ESM.
Snapshot matcher types move to @jest/expect.
@jest/expectjest-environment-jsdom migrates to ESM.
jest-environment-node migrates to ESM.
jest-jasmine2 and jest-runtime use a Symbol to pass the jest.setTimeout value instead of jasmine specific logic.
Symboljest.setTimeoutjest-phabricator migrates to ESM.
Makes the
requireResolveFunction argument mandatory in jest-resolve.requireResolveFunctionRemoves some type exports from
@jest/test-result.@jest/test-resultMakes the second constructor argument (
Context) non-optional in jest-runner.ContextMigrates
jest-snapshot to ESM.jest-snapshotExits with status 1 if no tests are found with the --findRelatedTests flag.
jest-core--findRelatedTestsPlatform4
Lowers the Node 16 requirement to 16.10 from 16.13 due to a Node bug causing memory and performance issues.
Drops support for Node v10 and v15 and targets first LTS 16.13.0.
Drops support for typescript@3.8, minimum version is now 4.3.
typescriptDrops support for typescript@4.2; the minimum supported version is now 4.3.
typescriptDeprecations to plan for
Deprecated1
Deprecates
jest-serializer in favour of using v8 APIs directly.jest-serializerv8API changes
Generated by DepDelta from published .d.ts files. Not mixed with prose notes.
- removed:
const transformer: SyncTransformer<TransformOptions> - removed:
default transformer - added:
const createTransformer: TransformerCreator<SyncTransformer<TransformOptions>, TransformOptions> - added:
const transformerFactory: { createTransformer: TransformerCreator<SyncTransformer<TransformOptions>, TransformOptions> } - added:
default transformerFactory
- removed:
export { loadPartialConfig } from '@babel/core' - removed:
export { loadPartialConfigAsync } from '@babel/core'