# require-top-level-describe

Rule `vitest/require-top-level-describe`. Enforce that all tests are in a top-level describe

- Source: vitest
- Technologies: Testing
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1697 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vitest/require-top-level-describe` | no | no | package `@vitest/eslint-plugin` | [docs](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md) |
| Oxlint | `vitest/require-top-level-describe` | no | no | plugin `vitest`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-top-level-describe.html) |
| Biome | `nursery/useTopLevelDescribe` | no | no | group nursery, since 2.6.9 | [docs](https://biomejs.dev/linter/rules/use-top-level-describe/) |

## Code examples

### Incorrect: the rule reports this

```js
test("adds two numbers", () => {});
```

```js
beforeEach(() => {});

describe("calculator", () => {
    test("adds two numbers", () => {});
});
```

### Correct: the rule accepts this

```js
describe("calculator", () => {
    beforeEach(() => {});

    test("adds two numbers", () => {});

    describe("division", () => {
        test("divides two numbers", () => {});
    });
});
```

Examples from the Biome documentation.

## Enable it

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

```js
import vitest from "@vitest/eslint-plugin";

export default [
  {
    plugins: { vitest },
    rules: {
      "vitest/require-top-level-describe": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "vitest"
  ],
  "rules": {
    "vitest/require-top-level-describe": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useTopLevelDescribe": "error"
      }
    }
  }
}
```

## Related rules

- [jest/require-top-level-describe](https://lintradar.dev/rules/jest/require-top-level-describe.md): Require test cases and hooks to be inside a `describe` block
- [vitest/prefer-to-have-length](https://lintradar.dev/rules/vitest/prefer-to-have-length.md): Enforce using toHaveLength()
- [vitest/prefer-to-have-been-called-times](https://lintradar.dev/rules/vitest/prefer-to-have-been-called-times.md): Suggest using `toHaveBeenCalledTimes()`
- [vitest/prefer-to-contain](https://lintradar.dev/rules/vitest/prefer-to-contain.md): Enforce using toContain()
- [vitest/prefer-strict-equal](https://lintradar.dev/rules/vitest/prefer-strict-equal.md): Enforce strict equal over equal
- [vitest/prefer-spy-on](https://lintradar.dev/rules/vitest/prefer-spy-on.md): Enforce using `vi.spyOn`

---

Web page: https://lintradar.dev/rules/vitest/require-top-level-describe. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
