jest mock mockname
test("mockFn.mockReset", () => {
const mockFn = jest.fn().mockImplementation(() => 43);
const MockClass = jest.fn();
new MockClass();
expect(mockFn()).toBe(43);
expect(mockFn.mock.calls).toHaveLength(1);
expect(MockClass.mock.instances).toHaveLength(1);
mockFn.mockReset();
MockClass.mockReset();
new MockClass();
expect(mockFn()).toBeUndefined();
expect(mockFn.mock.calls).toHaveLength(1);
expect(MockClass.mock.instances).toHaveLength(1);
});test("mockName", () => {
const mockFn = jest.fn().mockName("mockedFunction");
mockFn(); // comment me
expect(mockFn).toHaveBeenCalled();
});test("mock.calls", () => {
const mockFn = jest.fn();
mockFn(1, 2);
expect(mockFn.mock.calls).toEqual([[1, 2]]);
});