# no-duplicate-hooks

Rule `jest/no-duplicate-hooks`. Disallow duplicate setup and teardown hooks

- Source: jest
- Technologies: Testing
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 30.6M weekly downloads of presets that enable it
- Trend: +109.3% last quarter
- Rank: #475 by reach, #110 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `jest/no-duplicate-hooks` | no | no | package `eslint-plugin-jest` | [docs](https://github.com/jest-community/eslint-plugin-jest/blob/v29.17.2/docs/rules/no-duplicate-hooks.md) |
| Oxlint | `jest/no-duplicate-hooks` | no | no | plugin `jest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/jest/no-duplicate-hooks.html) |
| Biome | `suspicious/noDuplicateTestHooks` | yes | no | group suspicious, since 1.6.0 | [docs](https://biomejs.dev/linter/rules/no-duplicate-test-hooks/) |

## Code examples

### Incorrect: the rule reports this

```js
describe('foo', () => {
  beforeEach(() => {
    // some setup
  });
  beforeEach(() => {
    // some setup
  });
  test('foo_test', () => {
    // some test
  });
});

// Nested describe scenario
describe('foo', () => {
  beforeEach(() => {
    // some setup
  });
  test('foo_test', () => {
    // some test
  });
  describe('bar', () => {
    test('bar_test', () => {
      afterAll(() => {
        // some teardown
      });
      afterAll(() => {
        // some teardown
      });
    });
  });
});
```

### Correct: the rule accepts this

```js
describe('foo', () => {
  beforeEach(() => {
    // some setup
  });
  test('foo_test', () => {
    // some test
  });
});

// Nested describe scenario
describe('foo', () => {
  beforeEach(() => {
    // some setup
  });
  test('foo_test', () => {
    // some test
  });
  describe('bar', () => {
    test('bar_test', () => {
      beforeEach(() => {
        // some setup
      });
    });
  });
});
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import jest from "eslint-plugin-jest";

export default [
  {
    plugins: { jest },
    rules: {
      "jest/no-duplicate-hooks": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "jest"
  ],
  "rules": {
    "jest/no-duplicate-hooks": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noDuplicateTestHooks": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [vitest/no-duplicate-hooks](https://lintradar.dev/rules/vitest/no-duplicate-hooks.md): Disallow duplicate hooks and teardown hooks
- [jest/no-test-return-statement](https://lintradar.dev/rules/jest/no-test-return-statement.md): Disallow explicitly returning from tests
- [jest/no-disabled-tests](https://lintradar.dev/rules/jest/no-disabled-tests.md): Disallow disabled tests
- [jest/valid-expect](https://lintradar.dev/rules/jest/valid-expect.md): Enforce valid `expect()` usage
- [jest/expect-expect](https://lintradar.dev/rules/jest/expect-expect.md): Enforce assertion to be made in a test body
- [jest/no-conditional-expect](https://lintradar.dev/rules/jest/no-conditional-expect.md): Disallow calling `expect` conditionally

---

Web page: https://lintradar.dev/rules/jest/no-duplicate-hooks. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
