Skip to content

jest/prefer-called-with Style ​

What it does ​

Suggest using toBeCalledWith() or toHaveBeenCalledWith()

Example ​

javascript
// valid
expect(noArgsFunction).toBeCalledWith();
expect(roughArgsFunction).toBeCalledWith(expect.anything(), expect.any(Date));
expect(anyArgsFunction).toBeCalledTimes(1);
expect(uncalledFunction).not.toBeCalled();

// invalid
expect(someFunction).toBeCalled();
expect(someFunction).toHaveBeenCalled();

References ​

Released under the MIT License.