MockedFunction: MockInstance<
    ReturnType<T>,
    ArgsType<T>,
    T extends (this: infer C, ...args: any[]) => any ? C : never,
> & T

Wrap a function with mock definitions

Type Parameters

  • T extends (...args: any[]) => any
import { myFunction } from "./library";
jest.mock("./library");

const mockMyFunction = myFunction as jest.MockedFunction<typeof myFunction>;
expect(mockMyFunction.mock.calls[0][0]).toBe(42);