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 上编辑此页
上一页include
下一页setupFiles

#exclude

  • 类型: string[] | { patterns: string[]; override?: boolean }
  • 默认值: ['**/node_modules/**', '**/dist/**', '**/.{idea,git,cache,output,temp}/**']
  • CLI: --exclude "**/node_modules/**"

匹配 glob 规则的文件将不会被视为测试文件。

#示例

排除 node_modules 下的测试文件:

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

export default defineConfig({
  include: ['**/*.{test,spec}.?(c|m)[jt]s?(x)'],
  exclude: ['**/node_modules/**'],
});

#覆盖默认值

默认情况下,Rstest 会将你的自定义配置与默认配置进行合并。如果你希望覆盖默认的 exclude 配置,可以将 override 设置为 true。

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

export default defineConfig({
  include: ['**/*.{test,spec}.?(c|m)[jt]s?(x)'],
  exclude: {
    patterns: ['**/node_modules/**'],
    override: true,
  },
});