jest/max-nested-describe 樣式
作用
此規則強制限制巢狀 describe()
呼叫的最大深度,以提高測試程式碼的清晰度。
以下模式會被視為警告(預設選項為 { "max": 5 }
)
範例
javascript
// invalid
describe("foo", () => {
describe("bar", () => {
describe("baz", () => {
describe("qux", () => {
describe("quxx", () => {
describe("too many", () => {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
});
});
});
});
});
describe("foo", function () {
describe("bar", function () {
describe("baz", function () {
describe("qux", function () {
describe("quxx", function () {
describe("too many", function () {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
});
});
});
});
});
// valid
describe("foo", () => {
describe("bar", () => {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
describe("qux", () => {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
});
describe("foo2", function () {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
describe("foo", function () {
describe("bar", function () {
describe("baz", function () {
describe("qux", function () {
describe("this is the limit", function () {
it("should get something", () => {
expect(getSomething()).toBe("Something");
});
});
});
});
});
});