include
- 类型:
string[] - 默认值:
['**/*.{test,spec}.?(c|m)[jt]s?(x)'] - CLI:
--include '**/*.test.ts' --include '**/*.spec.ts'
匹配 glob 规则的文件将被视为测试文件。这些规则会相对于 root 解析(默认是 process.cwd())。
你可以运行 npx rstest list --filesOnly 来查看 Rstest 会包含的测试文件列表。
默认行为
默认情况下,Rstest 会匹配当前项目下所有文件名带有 .test. 或 .spec. 中缀的 JavaScript / TypeScript 文件。
下面是默认匹配模式的示例:
需要注意的是,如果你将 include 配置为 index.test.ts,Rstest 只会匹配根目录下的 index.test.ts。如果要匹配所有子目录中的 index.test.ts,需要使用 **/index.test.ts。