Pattern: Excessive describe nesting
Issue: -
Deeply nested describe blocks make test suites harder to read and understand. Keep nesting to a reasonable depth to maintain test clarity and structure.
Example of incorrect code:
describe("foo", () => {
describe("bar", () => {
describe("baz", () => {
describe("qux", () => {
describe("quxx", () => {
describe("too deep", () => {
it("should work", () => {
expect(value).toBe(true);
});
});
});
});
});
});
});
Example of correct code:
describe("foo", () => {
describe("bar", () => {
describe("baz", () => {
it("should work", () => {
expect(value).toBe(true);
});
});
});
});