> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# require-top-level-describe

[Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3)
## Configuration

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ jestPlugin.configs.all | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, jestPlugin } from '@rslint/core';

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/require-top-level-describe': 'error',
    },
  },
]);
```

## Rule Details

Require test cases (`test` / `it`) and hooks (`beforeAll`, `beforeEach`, `afterEach`, `afterAll`) to be inside a top-level `describe` block. Optionally limit how many top-level `describe` blocks a file may have via `maxNumberOfTopLevelDescribes`.

Examples of **incorrect** code for this rule:

```js
test('my test', () => {});
describe('test suite', () => {
  it('test', () => {});
});

beforeAll(() => {});
describe('test suite', () => {});
```

Examples of **correct** code for this rule:

```js
describe('test suite', () => {
  test('my test', () => {});
});

describe('test suite', () => {
  beforeEach(() => {});
  it('my test', () => {});
});
```

With `{ "maxNumberOfTopLevelDescribes": 1 }`:

```js
// incorrect — second top-level describe
describe('one', () => {});
describe('two', () => {});

// correct
describe('one', () => {
  describe('nested', () => {});
});
```

## Original Documentation

- [eslint-plugin-jest: require-top-level-describe](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/require-top-level-describe.md)
- [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/require-top-level-describe.ts)
