Upgrading @jest/globals 29 to 30
Breaking29.7.0 → 30.5.2Breaking27Security1Platform4Deprecated3New75Changed46Fixed190Other31
Fetching 31 releases from GitHub…28 / 31
SecurityIncreases jsdom to ^26.0.0 in jest-environment-jsdom and jest-environment-jsdom-abstract, addressing CVE-2024-37890.#15325 ↗
BreakingUpgrade verdict
27 breaking changes and 4 platform requirement changes and a security fix.
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 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.
Must act 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).
What you must change
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__esModuleAdds
mts and cts to the default moduleFileExtensions config.moduleFileExtensionsmtsctsUpdates the default
testMatch and testRegex options to support mjs, cjs, mts, and cts.testMatchtestRegexmjscjsmtsctsRemoves 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.
--initChanges
--filter to accept an object with shape { filtered: Array<string> } to match documentation.--filterExposes
globalConfig and contexts to TestSequencer.TestSequencerglobalConfigcontextsUpgrades JSDOM to v22 in
jest-environment-jsdom.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.
Stops rendering empty string children in the pretty-format React plugin.
pretty-formatValidates that CLI flags requiring arguments receive them in jest-cli.
jest-cliExcludes non-enumerable properties in object matching in @jest/expect-utils.
Fix the type of the testFailureExitCode config option in jest-schemas and jest-types.
testFailureExitCodePrint ArrayBuffer and DataView correctly in pretty-format.
ArrayBufferDataViewBundle all of Jest's modules into index.js.
index.jsAdds an ESM wrapper for all of Jest's modules.
Upgrades to glob@10.
Removes the MockFunctionMetadataType, MockFunctionMetadata and SpyInstance types from jest-mock.
MockFunctionMetadataTypeMockFunctionMetadataSpyInstanceSpecifying
testPathPatterns when programmatically calling watch must now be passed as new ....testPathPatternswatchPrevents false test failures caused by promise rejections handled asynchronously in jest-circus.
jest-circusWhen specifying paths on the command line, only match against relative paths of test files; testPathPattern becomes testPathPatterns taking a list.
testPathPatterntestPathPatterns--testPathPattern--testPathPatternsTestPathPatternswatchSecurity1
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.
Deprecations to plan for
Deprecated3
Notes deprecation of react-test-renderer in the React Native tutorial and pretty-format README.
react-test-rendererDeprecates getCallsite in @jest/source-map in favour of SourceMapSupport#getCallsite.
getCallsiteSourceMapSupport#getCallsiteRemoves and deprecates the
jest-repl package.jest-repl