jest/require-hook
eslint-plugin-jest
No autofix
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/require-hook": "error",
},
},
];The documentation shows no incorrect example for this rule.
import { enableAutoDestroy, mount } from '@vue/test-utils';
import { initDatabase, tearDownDatabase } from './databaseUtils';
enableAutoDestroy(afterEach);
beforeEach(initDatabase);
afterEach(tearDownDatabase);
describe('Foo', () => {
test('always returns 42', () => {
expect(global.getAnswer()).toBe(42);
});
});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/require-hook
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/require-hook": "error",
},
},
];jest/require-hook
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/require-hook": "error"
}
}Biome does not have this rule.
Prefer including a hint with external snapshots
Prefer mock resolved/rejected shorthands for promises