# bun:test/max-nested-describe

> Enforce a maximum depth of nested `describe()` calls

Every level of `describe` can add its own hooks and variables. To understand a test that sits many levels deep, you have to read all the blocks around it, and the test's full name gets long.

By default `describe` blocks can be 5 levels deep. Any `describe` nested deeper than that is reported.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"bun:test/max-nested-describe" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"bun:test/max-nested-describe" = ["error", {
  max = 5,
}]
```

{/* End of the generated section. */}

## Examples

These examples use a maximum of 2:

```toml bunfig.toml
[lint.rules]
"bun:test/max-nested-describe" = ["error", { max = 2 }]
```

Reported:

{/* bad {"options": [{"max": 2}], "count": 1} */}
```ts
import { describe, expect, test } from "bun:test";

describe("cart", () => {
  describe("checkout", () => {
    describe("with a coupon", () => {
      test("lowers the total", () => {
        expect(checkout({ coupon: "SAVE10" }).total).toBe(90);
      });
    });
  });
});
```

Not reported:

{/* good {"options": [{"max": 2}]} */}
```ts
import { describe, expect, test } from "bun:test";

describe("cart", () => {
  describe("checkout", () => {
    test("a coupon lowers the total", () => {
      expect(checkout({ coupon: "SAVE10" }).total).toBe(90);
    });
  });
});
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `max` | `5` | The number of levels allowed. |
