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

# Rstest utility

Rstest 提供了一些实用函数，通过 `rs` 工具方法可以帮助你更方便地进行测试。

你可以直接从 `@rstest/core` 导入 `rs`。

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

const fn = rs.fn();
fn.mockResolvedValue('foo');
```

更长的 `rstest` 工具方法仍然可以作为别名使用。

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

const fn = rstest.fn();
fn.mockResolvedValue('foo');
```

或者，你也可以像使用 `jest` 一样全局访问它（当启用了 [globals](/zh/config/test/globals.md) 配置时）。
