src/content/docs/linter/rules/no-excessive-nested-test-suites.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.6.0` - Diagnostic Category: [`lint/complexity/noExcessiveNestedTestSuites`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - This rule belongs to the following domains: - [`test`](/linter/domains#test) - Sources: - Same as [`jest/max-nested-describe`](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/max-nested-describe.md) - Same as [`vitest/max-nested-describe`](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md){
"linter": {
"rules": {
"complexity": {
"noExcessiveNestedTestSuites": "error"
}
}
}
}
This rule enforces a maximum depth to nested describe() in test files.
To improve code clarity in your tests, the rule limits nested describe to 5.
describe('foo', () => {
describe('bar', () => {
describe('baz', () => {
describe('qux', () => {
describe('quxx', () => {
describe('too many', () => {
it('should get something', () => {
expect(getSomething()).toBe('Something');
});
});
});
});
});
});
});
describe('foo', () => {
describe('bar', () => {
it('should get something', () => {
expect(getSomething()).toBe('Something');
});
});
describe('qux', () => {
it('should get something', () => {
expect(getSomething()).toBe('Something');
});
});
});