close
logo
Rstest
指南
配置
API
English
简体中文
指南
配置
API
English
简体中文
logo
Rstest
Overview

Test API

Expect
Test
Describe
Hooks

Rstest Utility

Mock modules
Mock functions
MockInstance
Fake timers
Utilities
📝 在 GitHub 上编辑此页
上一页Hooks
下一页Mock modules

#Rstest utility

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

你可以直接从 @rstest/core 导入 rstest,也可以使用它的别名 rs。

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

const fn = rstest.fn();
fn.mockResolvedValue('foo');
import { rs } from '@rstest/core';

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

或者,你也可以像使用 jest 一样全局访问它(当启用了 globals 配置时)。