> 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.

# max-nested-describe

[Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0)
## 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/max-nested-describe': 'error',
    },
  },
]);
```

## Rule Details

Enforce a maximum depth for nested `describe()` calls. Grouping tests with `describe` is useful, but too many nested levels make suites harder to read and navigate.

This rule counts every Jest suite call as a nesting level, including `fdescribe`, `xdescribe`, `describe.only`, `describe.skip`, and `describe.each`.

Examples of **incorrect** code for this rule (with the default `{ "max": 5 }`):

```javascript
describe('foo', () => {
  describe('bar', () => {
    describe('baz', () => {
      describe('qux', () => {
        describe('quxx', () => {
          describe('too many', () => {
            it('should get something', () => {
              expect(getSomething()).toBe('Something');
            });
          });
        });
      });
    });
  });
});

describe('foo', function () {
  describe('bar', function () {
    describe('baz', function () {
      describe('qux', function () {
        describe('quxx', function () {
          describe('too many', function () {
            it('should get something', () => {
              expect(getSomething()).toBe('Something');
            });
          });
        });
      });
    });
  });
});
```

Examples of **correct** code for this rule (with the default `{ "max": 5 }`):

```javascript
describe('foo', () => {
  describe('bar', () => {
    it('should get something', () => {
      expect(getSomething()).toBe('Something');
    });
  });

  describe('qux', () => {
    it('should get something', () => {
      expect(getSomething()).toBe('Something');
    });
  });
});

describe('foo2', function () {
  it('should get something', () => {
    expect(getSomething()).toBe('Something');
  });
});

describe('foo', function () {
  describe('bar', function () {
    describe('baz', function () {
      describe('qux', function () {
        describe('this is the limit', function () {
          it('should get something', () => {
            expect(getSomething()).toBe('Something');
          });
        });
      });
    });
  });
});
```

## Options

- First argument (optional): object with `max`
  - `max`: maximum allowed nesting depth for `describe()` calls. Default is `5`. A value of `0` disallows any `describe` block.

Examples of **correct** code with `{ "max": 2 }`:

```javascript
describe('foo', () => {
  describe('bar', () => {
    it('should get something', () => {
      expect(getSomething()).toBe('Something');
    });
  });
});
```

Examples of **incorrect** code with `{ "max": 2 }`:

```javascript
fdescribe('foo', () => {
  describe.only('bar', () => {
    describe.skip('baz', () => {
      it('should get something', () => {
        expect(getSomething()).toBe('Something');
      });
    });
  });
});
```

## Original Documentation

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