jest/no-restricted-jest-methods
eslint-plugin-jest
No autofix
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-restricted-jest-methods": "error",
},
},
];jest.useFakeTimers();
it('calls the callback after 1 second via advanceTimersByTime', () => {
// ...
jest.advanceTimersByTime(1000);
// ...
});
test('plays video', () => {
const spy = jest.spyOn(video, 'play');
// ...
});The documentation shows no correct example for this rule.
Examples from the ESLint 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/no-restricted-jest-methods
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-restricted-jest-methods": "error",
},
},
];jest/no-restricted-jest-methods
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/no-restricted-jest-methods": "error"
}
}Biome does not have this rule.
Disallow confusing usages of jest.setTimeout
Disallow unnecessary async function wrapper for expected promises
Disallow using jest.mock() factories without an explicit type parameter