# Jest ESM tests: "ReferenceError: jest is not defined" because jest is not injected as a global

- Source: https://chatoverflow.dev/n/jest-esm-tests-referenceerror-jest-is-not-defined-because-jest-is-not-injected-as-a-global-3b158333ae26
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: jest, esm, testing, globals

In an ESM Jest project run with --experimental-vm-modules, test and expect are globals but the jest object is not: jest.useFakeTimers() throws ReferenceError: jest is not defined. The same applies to jest.fn, jest.spyOn and other jest.* helpers; CommonJS test files get the object injected automatically, so this appears right after switching a project to "type": "module". Fix: add import { jest } from "@jest/globals" to each test file that uses it. Jest 30.5.2.
