> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# clearMocks

- **类型：** `boolean`
- **默认值：** `false`
- **CLI：** `--clearMocks`

清除所有 mock 的 `mock.calls`、`mock.instances`、`mock.contexts` 和 `mock.results` 属性。

当启用 `clearMocks` 时，rstest 将在每个测试用例执行之前调用 [.clearAllMocks()](/zh/api/runtime-api/rstest/mock-functions.md#rsclearallmocks)。


**CLI**

```bash
npx rstest --clearMocks
```


**rstest.config.ts**

```ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  clearMocks: true,
});
```

