Skip to content

Upgrading babel-jest 29 to 30

Breaking29.7.0 → 30.5.2Breaking31Platform2Deprecated3New74Changed52Fixed188Other30

BreakingUpgrade verdict

31 breaking changes and 2 platform requirement changes.

  • When importing CommonJS code from ES modules, the default export now matches Node's behavior, so code relying on the old __esModule unwrapping may need updates.
  • TypeScript module file extensions are now resolved by default.
  • Default test file patterns now also match the new module extensions.
  • The old way to generate a mock from a module has been removed.
Top 5 of 36 that need code or config changes

babel-jest publishes an official migration guide for version 30. It covers more than the release notes do.

Upgrading from Jest 29 to 30 ↗

Node.js requirement changed in 30.0.0-beta.6: ^14.15.0 || ^16.10.0 || >=18.0.0 → ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0.

Installs 180 packages in all (was 139).

Breaking31
Aligns CJS-from-ESM default export with Node: module.exports is always the ESM default and __esModule unwrapping is no longer applied.
module.exports__esModule
Adds mts and cts to default moduleFileExtensions config.
moduleFileExtensionsmtscts
Updates testMatch and testRegex default options to support mjs, cjs, mts, and cts.
testMatchtestRegexmjscjsmtscts
Removes deprecated jest.genMockFromModule().
jest.genMockFromModule()
Removes unnecessary defensive code.
Drops support for Node.js versions 14, 16, 19, 21 and 23.
Drops support for typescript@4.3; the minimum supported TypeScript version is now 5.4.
typescript
Removes deprecated expect matcher aliases such as .toBeCalled() and .toThrowError().
.toBeCalled().toBeCalledTimes().toBeCalledWith().lastCalledWith().nthCalledWith().toReturn().toReturnTimes().toReturnWith()
Removes the deprecated --init argument from jest-cli and jest-config.
jest-clijest-config@jest/types--init
Stops accepting reporters, coverageReporters, workerIdleMemoryLimit, cwd and runnerOptions in project configs; they now warn like other global-only options.
reporterscoverageReportersworkerIdleMemoryLimitcwdrunnerOptions
Changes --filter to accept an object with shape { filtered: Array<string> } to match documentation.
--filter
Exposes globalConfig and contexts to TestSequencer.
TestSequencerglobalConfigcontexts
Upgrades JSDOM to v22.
jest-environment-jsdom
Adds type inference for function parameters in CalledWith assertions.
CalledWith
Upgrades @sinonjs/fake-timers to v13.
@sinonjs/fake-timers
Makes passing globalConfig to the Runtime constructor mandatory.
RuntimeglobalConfig
Uses vm.compileFunction instead of vm.Script.
vm.compileFunctionvm.Script
Adds support for Error causes in snapshots.
Error.cause
Stops rendering empty string children in the pretty-format React plugin.
pretty-format
Validates CLI flags that require arguments receive them in jest-cli.
jest-cli
Excludes non-enumerable properties in object matching in @jest/expect-utils.
Fixes the type of the testFailureExitCode config option in jest-schemas and jest-types.
jest-schemasjest-typestestFailureExitCode
Prints ArrayBuffer and DataView correctly in pretty-format.
pretty-formatArrayBufferDataView
Bundles all of Jest's modules into index.js for performance.
index.js
Adds an ESM wrapper for all of Jest's modules.
Upgrades to glob@10.
glob
Increases the @babel/core peer dependency to ^7.11 for babel-jest and babel-preset-jest.
babel-jestbabel-preset-jest@babel/core
Removes the MockFunctionMetadataType, MockFunctionMetadata and SpyInstance types from jest-mock.
jest-mockMockFunctionMetadataTypeMockFunctionMetadataSpyInstance
Requires testPathPatterns passed to programmatic watch to be specified as a new value.
testPathPatternswatch
Prevents false test failures caused by promise rejections handled asynchronously in jest-circus.
jest-circus
Command line paths now match only against relative test file paths, and testPathPattern becomes testPathPatterns.
jest-clitestPathPatterntestPathPatterns--testPathPattern--testPathPatternswatchTestPathPatterns@jest/pattern
Platform2
Makes @types/jsdom a peer dependency of @jest-environment/jsdom-abstract.
@jest-environment/jsdom-abstract@types/jsdom
Drops support for Node.js version 16.
Deprecated3
Notes deprecation of react-test-renderer in the React Native tutorial and pretty-format README.
react-test-rendererpretty-format
Deprecates getCallsite in favour of SourceMapSupport#getCallsite.
getCallsiteSourceMapSupport#getCallsite
Removes and deprecates the jest-repl package.
jest-repl

Generated by DepDelta from published .d.ts files. Not mixed with prose notes.

  • changed: const createTransformer: TransformerCreator<SyncTransformer<TransformOptions>, TransformOptions> → const createTransformer: TransformerCreator<SyncTransformer<TransformerConfig>, TransformerConfig>
  • changed: const transformerFactory: { createTransformer: TransformerCreator<SyncTransformer<TransformOptions>, TransformOptions> } → const transformerFactory: { createTransformer: TransformerCreator<SyncTransformer<TransformerConfig>, TransformerConfig> }
  • added: interface TransformerConfig extends TransformOptions
  • added: property TransformerConfig.excludeJestPreset?: boolean