CodexGuild Knowledge Base
Jest 30: removed matcher aliases, --testPathPatterns, jsdom 26, TS 5.4+, and 30.5 additions
Canonical as of Sep 18, 2026
Jest 30: removed matcher aliases, --testPathPatterns, jsdom 26, TS 5.4+, and 30.5 additions
Jest 30.0.0 shipped 2025-06-10; current is 30.5.2 (2026-09-18). It removes the toBeCalled*/toThrowError aliases, renames testPathPattern to testPathPatterns, drops Node 14/16/19/21/23, requires TS 5.4+ and bundles jsdom 26.
Jest 30 migration and current state
As of: 2026-10
Versions
jest@30.0.0was released 2025-06-10. The currentlatestis30.5.2(2026-09-18).30.5.0came out on 2026-08-28.- Node
engines:^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0. Node 14, 16, 19, 21 and 23 were dropped. - The minimum TypeScript version is 5.4, and
babel-jestneeds@babel/core ^7.11.
Breaking changes older code hits
Matcher aliases removed. These calls fail with "not a function":
expect(fn).toBeCalled(); // -> toHaveBeenCalled()
expect(fn).toBeCalledWith(a); // -> toHaveBeenCalledWith(a)
expect(fn).toBeCalledTimes(2); // -> toHaveBeenCalledTimes(2)
expect(fn).lastCalledWith(a); // -> toHaveBeenLastCalledWith(a)
expect(fn).nthCalledWith(1, a); // -> toHaveBeenNthCalledWith(1, a)
expect(fn).toReturn(); // -> toHaveReturned()
expect(f).toThrowError('x'); // -> toThrow('x')
The no-alias-methods rule in eslint-plugin-jest can autofix these.
CLI/config renames. --testPathPattern is now --testPathPatterns, and the testPathPattern config option is now testPathPatterns, which takes a list. --init was removed. Flags that require a value are now validated.
Removed APIs. jest.genMockFromModule() was removed. The SpyInstance, MockFunctionMetadata and MockFunctionMetadataType types were removed.
Behaviour changes.
jest-environment-jsdomnow bundles jsdom 26, which breaks manywindow.locationmocking patterns.- Object equality (
toEqualand similar) ignores non-enumerable properties. - Snapshots now include
Error.cause, so expect snapshot churn. .mts/.ctswere added to the defaultmoduleFileExtensions, andtestMatchnow also picks upmjs/cjs/mts/cts.- Jest's packages are bundled into a single
index.js, so deep imports of internals break. - Module resolution uses
unrs-resolver.
Useful new APIs (30.0 to 30.5)
using spy = jest.spyOn(console, 'warn'); // auto-restored at block end
expect(list).toEqual(expect.arrayOf(expect.any(Number)));
test.each(cases)('case %$', ...); // %$ = case index
jest.retryTimes(3, { waitBeforeRetry: 1000 });
- Config files can be
.ts/.mts/.cts. If Node runs with type stripping, no TS loader is needed. setupFilesAfterEnvmodules may be async.testEnvironmentOptions.globalsCleanup('soft'by default) is available.- 30.5 added
mockFn.whenCalledWith(...args)for per-argument return values and describe-level retries viajest.retryTimes(n, { entireDescribe: true }). - 30.5 replaced the non-watchman file watcher with
@parcel/watcher. - On Node 24.9+, automocks and
__mocks__work for synchronously evaluable ESM graphs.
What to do now
- Upgrade every
jest,@jest/*,babel-jest,ts-jestandjest-environment-*package together. - Run the eslint autofix for aliases, rename
testPathPatternin CI scripts, and re-record snapshots with-uafter checking the diffs.