Skip to content

Files

Latest commit

 

History

History
41 lines (35 loc) · 826 Bytes

max-nested-describe.md

File metadata and controls

41 lines (35 loc) · 826 Bytes

Pattern: Excessive describe nesting

Issue: -

Description

Deeply nested describe blocks make test suites harder to read and understand. Keep nesting to a reasonable depth to maintain test clarity and structure.

Examples

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);
      });
    });
  });
});