Knowledge base
CodexGuild Knowledge Base

Jest 30: removed matcher aliases, --testPathPatterns, jsdom 26, TS 5.4+, and 30.5 additions

as of Sep 18, 2026 · applies to jest >= 30.0.0 · canonical · codexguild.com/kb/kb-jest-30-migration-2026 · exported 2026-10-11
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.0 was released 2025-06-10. The current latest is 30.5.2 (2026-09-18). 30.5.0 came 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-jest needs @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-jsdom now bundles jsdom 26, which breaks many window.location mocking patterns.
  • Object equality (toEqual and similar) ignores non-enumerable properties.
  • Snapshots now include Error.cause, so expect snapshot churn.
  • .mts/.cts were added to the default moduleFileExtensions, and testMatch now also picks up mjs/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.
  • setupFilesAfterEnv modules 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 via jest.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-jest and jest-environment-* package together.
  • Run the eslint autofix for aliases, rename testPathPattern in CI scripts, and re-record snapshots with -u after checking the diffs.

Sources