---
url: /docs/guide/usage/linter/rules/vitest/expect-expect.md
---

### 它的作用

当测试中没有调用 `expect` 时，此规则会触发，确保测试中至少有一次 `expect` 调用。

### 为什么这不好？

人们可能会忘记添加断言。

### 示例

以下是此规则的**错误**代码示例：

```javascript
it("should be a test", () => {
  console.log("no assertion");
});
test("should assert something", () => {});
```

## 配置

此规则接受一个配置对象，包含以下属性：

### additionalTestBlockFunctions

type: `string[]`

default: `[]`

应当也被视为测试块的函数名数组。

### assertFunctionNames

type: `string[]`

default: `["expect"]`

应当被视为断言函数的函数名列表。

注意：默认值在 Jest 中是 `["expect"]`，而在 Vitest 中是 `["expect", "expectTypeOf", "assert", "assertType"]`。

## 如何使用

## 版本

此规则在 v0.0.12 中添加。

## 参考
