MockedClass: MockInstance<
    InstanceType<T>,
    T extends new (...args: infer P) => any ? P : never,
    T extends new (...args: any[]) => infer C ? C : never,
> & {
    prototype: T extends { prototype: any } ? Mocked<T["prototype"]> : never;
} & T

Wrap a class with mock definitions

Type Parameters

import { MyClass } from "./library";
jest.mock("./library");

const mockedMyClass = MyClass as jest.MockedClass<typeof MyClass>;

expect(mockedMyClass.mock.calls[0][0]).toBe(42); // Constructor calls
expect(mockedMyClass.prototype.myMethod.mock.calls[0][0]).toBe(42); // Method calls