jest/prefer-called-with
eslint-plugin-jest
No autofix
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-called-with": "error",
},
},
];expect(sendEmail).toHaveBeenCalled();expect(sendEmail).toBeCalled();expect(sendEmail).toHaveBeenCalledOnce();expect(sendEmail).toHaveBeenCalledWith("[email protected]", expect.anything());
expect(sendEmail).toHaveBeenCalledExactlyOnceWith("[email protected]");
expect(refresh).toHaveBeenCalledWith();
expect(sendEmail).toHaveBeenCalledTimes(1);
expect(sendEmail).not.toHaveBeenCalled();Examples from the Biome documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
jest/prefer-called-with
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-called-with": "error",
},
},
];jest/prefer-called-with
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/prefer-called-with": "error"
}
}nursery/useCalledWith
nursery · since 2.6.8
{
"linter": {
"rules": {
"nursery": {
"useCalledWith": "error"
}
}
}
}Enforce using toBeCalledWith() or toHaveBeenCalledWith()
Suggest using the built-in equality matchers
Enforces a maximum depth to nested describe calls
Prefer having hooks in a consistent order