close

max-nested-describe

Unreleased

Configuration

rslint.config.ts
import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/max-nested-describe': 'error',
    },
  },
]);

Rule Details

Limits the depth of nested describe calls. Shallow suite hierarchies keep test names, reports, and inherited suite setup easier to understand.

The rule recognizes Rstest globals and APIs imported from @rstest/core, rstack/test, and @rstest/playwright, including aliases, namespace and CommonJS imports, import.meta.rstest, Playwright test.describe, parameterized suites, conditional suites, chained suite modifiers, and suite callbacks passed by reference. It does not treat similarly named APIs from other test frameworks or locally shadowed functions as Rstest suites.

Incorrect

describe('checkout', () => {
  describe('signed-in customer', () => {
    describe('saved payment method', () => {
      test('places the order', () => {});
    });
  });
});

Correct

describe('checkout for a signed-in customer', () => {
  describe('saved payment method', () => {
    test('places the order', () => {});
  });
});

Options

{
  "rstest/max-nested-describe": [
    "error",
    {
      "max": 2
    }
  ]
}
OptionTypeDefaultDescription
maxinteger5Set the maximum allowed suite nesting depth.