type ProjectConfig = Omit<
RstestConfig,
'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'bail'
>;
type Projects = (string | ProjectConfig)[];[<rootDir>]Define multiple test projects. It can be an array of directories, configuration files, or glob patterns, or an object.
Rstest will run the tests for each project according to the configuration defined in each project, and the test results from all projects will be combined and displayed.
You can filter the specified projects to run by using the --project option.
If there is no projects field, rstest will treat current directory as a single project.
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',
},
],
});reporters, pool, and isolate are not valid in a project configuration.import { defineConfig } from '@rstest/core';
import sharedConfig from '../shared/rstest.config';
export default defineConfig({
...sharedConfig,
});rstest supports configuring projects inline in the projects field. This lets you define multiple test projects in a single root without creating separate config files for each test project.
import { defineConfig } from '@rstest/core';
export default defineConfig({
projects: [
// 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',
},
],
});Rstest supports nested project definitions within the rstest config of sub-projects. This allows you to define more test projects in sub-projects without having to define all projects in the root project.
This is especially useful when your sub-projects need to support multiple test environments or multiple configurations.
Define Node.js and browser test environments for packages/pkg-a:
import { defineConfig } from '@rstest/core';
export default defineConfig({
projects: [
{
name: 'node',
include: ['tests/node/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
},
{
name: 'react',
include: ['tests/react/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
testEnvironment: 'jsdom',
},
],
});