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