🔧 This rule is automatically fixable by the
--fix
CLI option.
For expecting a mock or spy to have been called once, jest-extended
provides
the toHaveBeenCalledOnce
matcher.
This rule triggers a warning if an expect
assertion is found asserting that a
mock or spy is called once using toHaveBeenCalledTimes(1)
.
The following patterns are considered warnings:
expect(myMock).toHaveBeenCalledTimes(1);
expect(mySpy).not.toHaveBeenCalledTimes(1);
The following patterns are not considered warnings:
expect(myMock).toHaveBeenCalledOnce();
expect(mySpy).not.toHaveBeenCalledOnce();