You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use .toHaveBeenCalledOnce to check if a Mock was called exactly one time.
{`test('passes only if mock was called exactly once', () => {
const mock = jest.fn();\n
expect(mock).not.toHaveBeenCalled();
mock();
expect(mock).toHaveBeenCalledOnce();
});`}
.toHaveBeenCalledOnceWith()
Use .toHaveBeenCalledOnceWith to check if a Mock was called exactly one time with the expected values.
{`test('passes only if mock was called exactly once with the expected value', () => {
const mock = jest.fn();\n
expect(mock).not.toHaveBeenCalled();
mock('hello');
expect(mock).toHaveBeenCalledOnceWith('hello');
});`}