When testing a module that has a dependency in a different file. When assigning that module to be jest.Mock typescript gives an error that the method mock
jest.Mock
mock
I use the pattern from @types/jest/index.d.ts just above the type def for Mocked (line 515):
import { Api } from "../api"; jest.mock("../api"); const myApi: jest.Mocked = new Api() as any; myApi.myApiMethod.mockImplementation(() => "test");