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();
How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny jest/prefer-called-with --jest-plugin
json
{
"plugins": ["jest"],
"rules": {
"jest/prefer-called-with": "error"
}
}