max-nested-describe
July 15, 2026 Β· View on GitHub
π Enforce a maximum depth for nested describe blocks.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
Deeply nested describe blocks make a test file hard to read: the setup for a test is spread across many enclosing scopes, and the indentation alone obscures what is being tested. A deep nest usually means the suite is trying to do too much and should be split into separate files.
This rule reports describe/suite blocks nested beyond a configurable depth (default 5).
Options
{
'node-test/max-nested-describe': [
'error',
{
max: 5 // maximum nesting depth (default: 5)
}
]
}
Examples
import {describe, it} from 'node:test';
// β (with max: 2)
describe('a', () => {
describe('b', () => {
describe('c', () => {
it('is too deep', () => {});
});
});
});
// β
(with max: 2)
describe('a', () => {
describe('b', () => {
it('is fine', () => {});
});
});