type ProjectConfig = Omit<
RstestConfig,
'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'bail'
>;
type Projects = (string | ProjectConfig)[];[<rootDir>]定义多个测试项目,可以是一个目录、配置文件或 glob 模式,也可以是一个对象。 Rstest 将会按照各个项目定义的配置运行对应的测试,所有项目的测试结果将会合并展示。
import { defineConfig } from '@rstest/core';
export default defineConfig({
projects: [
// A monorepo: each package directory is a project
'packages/*',
// All projects under the apps directory that provide an rstest config file
'apps/**/rstest.config.ts',
// A specific project directory
'<rootDir>/services/auth',
// A specific project's config file
'./projects/web/rstest.config.ts',
// inline project configs
{
name: 'node',
include: ['tests/node/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
},
{
name: 'react',
include: ['tests/react/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
testEnvironment: 'jsdom',
},
],
});更多关于项目配置的信息,请参考多项目测试。