From v29 to v30
Upgrading Jest from v29 to v30? This guide aims to help refactoring your configuration and tests.
info
See changelog for the full list of changes.
note
Upgrading from an older version? You can see the upgrade guide from v28 to v29 here.
Compatibility
- Jest 30 drops support for Node 14, 16, 19, and 21. The minimum supported Node versions are now 18.x. Ensure your environment is using a compatible Node release before upgrading.
- The minimum TypeScript version is now 5.4. Update TypeScript, if you are using type definitions of Jest (or any of its packages).
- The
jest-environment-jsdom
package now uses JSDOM v26. This update may introduce behavior changes in the DOM environment. If you encounter differences in DOM behavior or new warnings, refer to the JSDOM release notes for v21–26.
Jest Expect & Matchers
Removal of Alias Matcher Functions
All alias matcher names have been removed in favor of their primary names. If you have been using older, deprecated matcher names, you will need to update your tests:
- Removed aliases and their replacements:
expect(fn).toBeCalled()
→expect(fn).toHaveBeenCalled()
expect(fn).toBeCalledTimes(n)
→expect(fn).toHaveBeenCalledTimes(n)
expect(fn).toBeCalledWith(arg)
→expect(fn).toHaveBeenCalledWith(arg)
expect(fn).lastCalledWith(arg)
→expect(fn).toHaveBeenLastCalledWith(arg)
expect(fn).nthCalledWith(n, arg)
→expect(fn).toHaveBeenNthCalledWith(n, arg)
expect(fn).toReturn()
→expect(fn).toHaveReturned()
expect(fn).toReturnTimes(n)
→expect(fn).toHaveReturnedTimes(n)
expect(fn).toReturnWith(val)