Skip to content

Upgrading @jest/globals 29 to 30

Breaking29.7.0 → 30.5.2Breaking27Security1Platform4Deprecated3New75Changed46Fixed190Other31

Fetching 31 releases from GitHub…28 / 31
BreakingUpgrade verdict

27 breaking changes and 4 platform requirement changes and a security fix.

  • 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 updating.
  • Jest now resolves TypeScript module files by default, which changes which files are picked up.
  • Jest now finds test files with more extensions by default, which can change which tests run.
  • The old `jest.genMockFromModule()` helper is gone; use `jest.createMockFromModule()` instead.
Top 5 of 35 that need code or config changes

@jest/globals 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 203 packages in all (was 160).

Breaking27
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 the default moduleFileExtensions config.
moduleFileExtensionsmtscts
Updates the default testMatch and testRegex options to support mjs, cjs, mts, and cts.
testMatchtestRegexmjscjsmtscts
Removes the deprecated jest.genMockFromModule().
jest.genMockFromModule()
Removes unnecessary defensive code from @jest/environment.
Removes the .toBeCalled(), .toBeCalledTimes(), .toBeCalledWith(), .lastCalledWith(), .nthCalledWith(), .toReturn(), .toReturnTimes(), .toReturnWith(), .lastReturnedWith(), .nthReturnedWith() and…
.toBeCalled().toBeCalledTimes().toBeCalledWith().lastCalledWith().nthCalledWith().toReturn().toReturnTimes().toReturnWith()
Removes the deprecated --init argument from jest-cli, jest-config and @jest/types.
--init
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 in jest-environment-jsdom.
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.
Stops rendering empty string children in the pretty-format React plugin.
pretty-format
Validates that CLI flags requiring arguments receive them in jest-cli.
jest-cli
Excludes non-enumerable properties in object matching in @jest/expect-utils.
Fix the type of the testFailureExitCode config option in jest-schemas and jest-types.
testFailureExitCode
Print ArrayBuffer and DataView correctly in pretty-format.
ArrayBufferDataView
Bundle all of Jest's modules into index.js.
index.js
Adds an ESM wrapper for all of Jest's modules.
Upgrades to glob@10.
Removes the MockFunctionMetadataType, MockFunctionMetadata and SpyInstance types from jest-mock.
MockFunctionMetadataTypeMockFunctionMetadataSpyInstance
Specifying testPathPatterns when programmatically calling watch must now be passed as new ....
testPathPatternswatch
Prevents false test failures caused by promise rejections handled asynchronously in jest-circus.
jest-circus
When specifying paths on the command line, only match against relative paths of test files; testPathPattern becomes testPathPatterns taking a list.
testPathPatterntestPathPatterns--testPathPattern--testPathPatternsTestPathPatternswatch
Security1
Increases jsdom to ^26.0.0 in jest-environment-jsdom and jest-environment-jsdom-abstract, addressing CVE-2024-37890.
Platform4
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.
Increases the @babel/core peer dependency to ^7.11 for babel-jest and babel-preset-jest.
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-renderer
Deprecates getCallsite in @jest/source-map in favour of SourceMapSupport#getCallsite.
getCallsiteSourceMapSupport#getCallsite
Removes and deprecates the jest-repl package.
jest-repl