Skip to content

Upgrading babel-jest 27 to 28

Breaking27.5.1 → 28.1.3Breaking50Platform4Deprecated1New36Changed22Fixed44Other17

BreakingUpgrade verdict

48 breaking changes and 4 platform requirement changes.

  • 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.
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).

Breaking48
Removes the testURL config option in favor of testEnvironmentOptions.url.
testURLtestEnvironmentOptions.url
Stops shipping jest-environment-jsdom by default.
jest-environment-jsdom
Stops shipping jest-jasmine2 by default.
jest-jasmine2
Renames the moduleLoader config option to runtime.
moduleLoaderruntime
Renames the extraGlobals config option to sandboxInjectedGlobals.
extraGlobalssandboxInjectedGlobals
Adds default browser condition to exportConditions for the jsdom environment.
jest-environment-jsdomexportConditionsbrowser
Adds default node and node-addon conditions to exportConditions for the node environment.
jest-environment-nodeexportConditionsnodenode-addon
Renames the timers configuration option to fakeTimers.
@jest/fake-timerstimersfakeTimers
Renames exported utility types and removes ArgumentsOf, ArgsType, ConstructorArgumentsOf in favor of TS builtins.
ClassLikeFunctionLikeConstructorLikeKeysMethodLikeKeysPropertyLikeKeysArgumentsOfArgsTypeConstructorArgumentsOf
Removes browser option from resolver options; use conditions: ['browser'] instead.
browserconditions
jest-worker defaults to advanced serialization when using child process workers.
jest-worker
Adds mjs and cjs to the default moduleFileExtensions config.
moduleFileExtensionsmjscjs
expect no longer supports importing build/utils.
build/utils
jest-config removes the getTestEnvironment export.
getTestEnvironment
jest-config renames the config option name to id.
nameid
Removes Config.Glob and Config.Path from jest-types.
Config.GlobConfig.Path
Defaults jest-haste-map to the node crawler instead of shelling out to find when watchman is not enabled.
jest-haste-mapwatchman
Removes the undocumented --timers CLI option.
--timers
Throws an error instead of a warning when multiple configs are used.
Stops normalizing long deprecated options preprocessorIgnorePatterns, scriptPreprocessor, setupTestFrameworkScriptFile and testPathDirs.
preprocessorIgnorePatternsscriptPreprocessorsetupTestFrameworkScriptFiletestPathDirs
Moves the TestWatcher class to the jest-watcher package.
TestWatcherjest-watcher
Upgrades jsdom to 19.0.0 in jest-environment-jsdom.
jest-environment-jsdom
Passes global config to the Jest environment constructor for the jsdom environment.
jest-environment-jsdomjest-environment-node
Makes the second constructor argument context mandatory for the jsdom environment.
jest-environment-jsdomcontextjest-environment-node
Allows jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag.
jest.useFakeTimers()projectConfig.fakeTimers
HasteMap.create now returns a promise.
HasteMap.create
Improves the usage of the jest.fn generic type argument.
jest.fn
Adds support for package.json exports in jest-resolve.
jest-resolvepackage.jsonexports
Runtime.createHasteMap now returns a promise.
Runtime.createHasteMap
Removes Context type export from jest-runtime; import it from @jest/test-result instead.
Context@jest/test-result
Requires process() and processAsync() methods to always return structured data.
process()processAsync()
PatternPrompt now takes entityName as third constructor parameter instead of this._entityName.
PatternPromptentityNamethis._entityName
Allows only absolute workerPath in jest-worker.
workerPath
babel-jest passes rootDir as root in Babel's options.
babel-jestrootDirroot
Fixes false positives when looking for an undefined prop in @jest/expect-utils.
@jest/expect-utils
Moves all jasmine specific types from @jest/types to its own package.
@jest/typesjest-jasmine2jest-types
babel-jest now only exports createTransformer.
createTransformer
expect migrates to ESM.
Snapshot matcher types move to @jest/expect.
@jest/expect
jest-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.setTimeout
jest-phabricator migrates to ESM.
Makes the requireResolveFunction argument mandatory in jest-resolve.
requireResolveFunction
Removes some type exports from @jest/test-result.
@jest/test-result
Makes the second constructor argument (Context) non-optional in jest-runner.
Context
Migrates jest-snapshot to ESM.
jest-snapshot
Exits with status 1 if no tests are found with the --findRelatedTests flag.
jest-core--findRelatedTests
Platform4
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.
typescript
Drops support for typescript@4.2; the minimum supported version is now 4.3.
typescript
Deprecated1
Deprecates jest-serializer in favour of using v8 APIs directly.
jest-serializerv8

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'