Error:
The "actual" argument in expect(actual).toHaveBeenCalled() must be a spy
Minimal not-working example:
const mockFn = jest.fn();
mockFn();
expect(mockFn).toHaveBeenCalled();
Question: is jest.fn()
not a spy?
Error:
The "actual" argument in expect(actual).toHaveBeenCalled() must be a spy
Minimal not-working example:
const mockFn = jest.fn();
mockFn();
expect(mockFn).toHaveBeenCalled();
Question: is jest.fn()
not a spy?
I tried the below implementation which worked for me,
it("should call mock function when button is clicked", () => {
const mockFn = jest.fn();
const tree = shallow(<button name="button test" handleHandler={mockFn} />);
tree.simulate("click");
mockFn();
expect(mockFn).toHaveBeenCalled();
});