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', () => {});
	});
});