Migrating to Jest v30.0.0
Version v30.0.0 introduces 11 breaking changes. This guide details how to update your code.
Released: 6/10/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
`globalsCleanupMode``--waitNextEventLoopTurnForUnhandledRejectionEvents``ArrayOf``excludeJestPreset``babel-preset-jest``expect(fn).toHaveBeenCalledWith(expect.objectContaining(...))``waitNextEventLoopTurnForUnhandledRejectionEvents` flag`jest.retryTimes``setupFilesAfterEnv``TestCaseResultObject``onTestCaseResult``buildArgv``moduleFileExtensions``testMatch``testRegex``jest.config.cts``preset``rootDir``esbuild-register`TS config docblock loaderOpen handles grouping`perfStats``--filter``--listTests``--json``TestSequencer``globalConfig``contexts``%$` in `jest-each``jest.genMockFromModule()``jest.createMockFromModule()``jest-environment-jsdom``JSDOM v22``@jest/environment-jsdom-abstract``jest-environment-node``Symbol` dispose symbols`CalledWith` assertions`TypedArray` comparison`@sinonjs/fake-timers` v13`advanceTimersToFrame()``SERIALIZABLE_PROPERTIES``jest.spyOn``using` keywordDEC mode 2026`file://` URLs`jest-resolver``import.meta.filename``import.meta.dirname``import.meta.resolve``Runtime` constructor`globalConfig``unstable_unmockModule``onGenerateMock``vm.compileFunction``vm.Script`Breaking Changes
●Issue #1
[jest-config] Default `moduleFileExtensions` now includes `mts` and `cts`.
✓Solution
If you rely on Jest not picking up `.mts` or `.cts` files by default, you must explicitly configure `moduleFileExtensions` in your Jest config to exclude them.
●Issue #2
[jest-config] Default `testMatch` and `testRegex` options were updated to support `mjs`, `cjs`, `mts`, and `cts` files.
✓Solution
Review and update your custom `testMatch` or `testRegex` if you were relying on the previous defaults and need to maintain specific file type inclusions/exclusions.
●Issue #3
[@jest/core] The `--filter` CLI option now expects an object with shape `{ filtered: Array<string> }` instead of a string array directly.
✓Solution
Update scripts or configurations that use `--filter` to pass the required JSON object structure, e.g., `--filter='{"filtered": ["file1.js"]}'`.
●Issue #4
[@jest/core, @jest/test-sequencer] `TestSequencer` API now exposes `globalConfig` & `contexts` in its methods.
✓Solution
If you implemented a custom `TestSequencer`, update its methods to accept the new arguments.
●Issue #5
[@jest/environment] Deprecated `jest.genMockFromModule()` has been removed.
✓Solution
Use `jest.createMockFromModule()` instead of `jest.genMockFromModule()`.
●Issue #6
[@jest/environment] Unnecessary defensive code was removed.
✓Solution
No action required unless you were relying on specific internal defensive behaviors that are now gone.
●Issue #7
[jest-environment-jsdom] JSDOM has been upgraded to v22.
✓Solution
Review JSDOM v22 release notes for any breaking changes that might affect your tests relying on DOM manipulation.
●Issue #8
[expect, @jest/expect] Type inference for function parameters in `CalledWith` assertions has been added, which changes internal behavior.
✓Solution
If you were relying on specific type coercion or behavior in `toHaveBeenCalledWith` with function arguments, re-verify assertions.
●Issue #9
[@jest/fake-timers] `@sinonjs/fake-timers` was upgraded to v13.
✓Solution
Review changes in `@sinonjs/fake-timers` v13, although Jest aims to abstract most breaking changes.
●Issue #10
[jest-runtime] The `Runtime` constructor now mandates passing `globalConfig`.
✓Solution
Ensure you pass `globalConfig` when instantiating `Runtime`.
●Issue #11
[jest-runtime] Switched from using `vm.Script` to `vm.compileFunction` for code execution.
✓Solution
This is an internal change; no direct user action is usually required unless you interact deeply with Jest's runtime internals.
Migration Steps
- 1Run `npm install jest@^30.0.0`.
- 2Follow the migration guide: [Upgrading from Jest 29 to 30](https://jestjs.io/docs/upgrading-to-jest30).
Release Summary
Jest 30 is a substantial major release after a three-year gap, introducing numerous features like new matchers, improved configuration loading for TypeScript modules (mts/cts), and significant internal upgrades to JSDOM and fake timers. Users must consult the migration guide due to several breaking API changes.
Need More Details?
View the full release notes and all changes for Jest v30.0.0.
View Full Changelog