Pattern: Duplicate hook
Issue: -
Using multiple instances of the same hook (beforeEach, afterEach, etc.) within a describe block creates confusion and may lead to unexpected behavior. Each hook type should only be used once per scope.
Example of incorrect code:
describe("suite", () => {
beforeEach(() => {
setup1();
});
beforeEach(() => {
setup2();
});
test("foo", () => {
expect(value).toBe(true);
});
});
Example of correct code:
describe("suite", () => {
beforeEach(() => {
setup1();
setup2();
});
test("foo", () => {
expect(value).toBe(true);
});
});