Upgrading babel-jest 29 to 30
Breaking29.7.0 → 30.5.2Breaking31Platform2Deprecated3New74Changed52Fixed188Other30
BreakingUpgrade verdict
31 breaking changes and 2 platform requirement changes.
In plain terms
- 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.
Must act 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).
What you must change
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__esModuleAdds
mts and cts to default moduleFileExtensions config.moduleFileExtensionsmtsctsUpdates
testMatch and testRegex default options to support mjs, cjs, mts, and cts.testMatchtestRegexmjscjsmtsctsRemoves 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.
typescriptRemoves 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--initStops accepting reporters, coverageReporters, workerIdleMemoryLimit, cwd and runnerOptions in project configs; they now warn like other global-only options.
reporterscoverageReportersworkerIdleMemoryLimitcwdrunnerOptionsChanges
--filter to accept an object with shape { filtered: Array<string> } to match documentation.--filterExposes
globalConfig and contexts to TestSequencer.TestSequencerglobalConfigcontextsUpgrades JSDOM to v22.
jest-environment-jsdomAdds type inference for function parameters in
CalledWith assertions.CalledWithUpgrades
@sinonjs/fake-timers to v13.@sinonjs/fake-timersMakes passing globalConfig to the Runtime constructor mandatory.
RuntimeglobalConfigUses vm.compileFunction instead of vm.Script.
vm.compileFunctionvm.ScriptAdds support for Error causes in snapshots.
Error.causeStops rendering empty string children in the pretty-format React plugin.
pretty-formatValidates CLI flags that require arguments receive them in
jest-cli.jest-cliExcludes 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-typestestFailureExitCodePrints ArrayBuffer and DataView correctly in pretty-format.
pretty-formatArrayBufferDataViewBundles all of Jest's modules into index.js for performance.
index.jsAdds an ESM wrapper for all of Jest's modules.
Upgrades to glob@10.
globIncreases the @babel/core peer dependency to ^7.11 for babel-jest and babel-preset-jest.
babel-jestbabel-preset-jest@babel/coreRemoves the MockFunctionMetadataType, MockFunctionMetadata and SpyInstance types from jest-mock.
jest-mockMockFunctionMetadataTypeMockFunctionMetadataSpyInstanceRequires testPathPatterns passed to programmatic watch to be specified as a new value.
testPathPatternswatchPrevents false test failures caused by promise rejections handled asynchronously in
jest-circus.jest-circusCommand line paths now match only against relative test file paths, and testPathPattern becomes testPathPatterns.
jest-clitestPathPatterntestPathPatterns--testPathPattern--testPathPatternswatchTestPathPatterns@jest/patternPlatform2
Makes @types/jsdom a peer dependency of @jest-environment/jsdom-abstract.
@jest-environment/jsdom-abstract@types/jsdomDrops support for Node.js version 16.
Deprecations to plan for
Deprecated3
Notes deprecation of react-test-renderer in the React Native tutorial and pretty-format README.
react-test-rendererpretty-formatDeprecates getCallsite in favour of SourceMapSupport#getCallsite.
getCallsiteSourceMapSupport#getCallsiteRemoves and deprecates the
jest-repl package.jest-replAPI changes
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