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,
  },
});