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

Test Configurations

root
name
include
exclude
setupFiles
projects
update
globals
passWithNoTests
includeSource
testNamePattern
env
retry
testTimeout
hookTimeout
maxConcurrency
pool
isolate
testEnvironment
clearMocks
resetMocks
restoreMocks
unstubEnvs
unstubGlobals
coverage
reporters
hideSkippedTests
slowTestThreshold
snapshotFormat
resolveSnapshotPath
printConsoleTrace
onConsoleLog
disableConsoleIntercept

Build Configurations

plugins
source
output
resolve
tools
dev
performance
📝 在 GitHub 上编辑此页
上一页testEnvironment
下一页resetMocks

#clearMocks

  • 类型: boolean
  • 默认值: false
  • CLI: --clearMocks

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

当启用 clearMocks 时,rstest 将在每个测试用例执行之前调用 .clearAllMocks()。

CLI
rstest.config.ts
import { defineConfig } from '@rstest/core';

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