A jest.mock() or jest.fn() is not behaving as expected — either not being called, not returning the mocked value, or not intercepting the real implementation.
// Jest automatically hoists jest.mock() calls to the top
jest.mock('./api', () => ({
fetchUsers: jest.fn().mockResolvedValue([{ id: 1 }]),
}));
import { fetchUsers } from './api'; // Mock is already in placejest.mock() is automatically hoisted to the top of the file. This ensures the mock is set up before any imports.
afterEach(() => {
jest.clearAllMocks();
});
// Or globally in jest.config.ts:
export default {
clearMocks: true,
};Clear mock state between tests to prevent test pollution.
ObserveOne validates mock configurations and detects when mocks drift from real implementations.
Start Monitoring FreeJest could not resolve a module import. The file may not exist, the path may be wrong, or the module resolution config may be misconfigured.
Jest encountered syntax it cannot parse. This usually means a file needs to be transformed (e.g., TypeScript, JSX, ESM) but the transformer is not configured.
The rendered output does not match the stored snapshot. The component output changed since the snapshot was last updated.
An async test did not complete within the default 5-second timeout. The async operation may be hanging, or done() was never called.
A Promise was rejected but no .catch() handler or try/catch block caught the error. This can cause flaky tests or missed failures.