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
, orit
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);
});
});
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny jest/no-confusing-set-timeout --jest-plugin
json
{
"plugins": ["jest"],
"rules": {
"jest/no-confusing-set-timeout": "error"
}
}