Skip to content

jest/no-confusing-set-timeout Style

What it does

Disallow confusing usages of jest.setTimeout

Why is this bad?

  • being called anywhere other than in global scope
  • being called multiple times
  • being called after other Jest functions like hooks, describe, test, or it

Example

All of these are invalid case:

javascript
escribe("test foo", () => {
  jest.setTimeout(1000);
  it("test-description", () => {
    // test logic;
  });
});

describe("test bar", () => {
  it("test-description", () => {
    jest.setTimeout(1000);
    // test logic;
  });
});

test("foo-bar", () => {
  jest.setTimeout(1000);
});

describe("unit test", () => {
  beforeEach(() => {
    jest.setTimeout(1000);
  });
});

References

Released under the MIT License.