---
url: /docs/guide/usage/linter/rules/jest/no-confusing-set-timeout.md
---

### 它的作用

禁止对 `jest.setTimeout` 的混淆性使用。

### 为什么这不好？

* 在全局作用域之外的任何地方调用
* 多次调用
* 在其他 Jest 函数之后调用，例如 hooks、`describe`、`test` 或 `it`

### 示例

以下均为无效示例：

```javascript
escribe("test foo", () => {
  jest.setTimeout(1000);
  it("test-description", () => {
    // 测试逻辑；
  });
});

describe("test bar", () => {
  it("test-description", () => {
    jest.setTimeout(1000);
    // 测试逻辑；
  });
});

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

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

## 如何使用

## 版本

此规则在 v0.0.14 中添加。

## 参考资料
