Test projects
Rstest lets you run multiple test projects in a single Rstest process, each with its own test configuration and environment.
In an unfiltered, one-shot Node.js run without coverage, bail, or failure selection, a project can start running tests while another is still building. Runs with globalSetup or a reporter that needs the complete file selection in onTestRunStart wait for all projects to build before dispatching tests.
In Node.js mode, Rstest limits concurrent environment builds to the number of CPUs available to the process by default. The pool.maxWorkers option controls how many workers execute test files.
Use cases
- Monorepo projects: Each sub-package or app has its own test setup or build config.
- Mixed environments: Run Node.js,
jsdom, and Browser Mode tests side by side. - Directory-specific settings: Apply distinct timeouts, setup files, or plugins to different test folders.
Example
Point projects at your workspace directories in the root config. Rstest treats each matching subdirectory as an independent project and loads its own rstest.config.ts if present:
Configuration
When projects is defined, Rstest runs each matched project with its own config and merges all test results into a single report.
- If
projectsis omitted, Rstest treats the current directory as a single project. - If
projectsis an empty array ([]), Rstest throws aNo projects founderror. - Every resolved project must have a unique
name; duplicate names fail at startup with the list of conflicting projects.
Configuration syntax
Each entry in projects can be:
- Directory path: Loads the project in that directory (and its config file, if present).
- Configuration file path: Loads that specific config file as a project.
- Glob pattern: Matches multiple project directories or config files.
- Inline configuration object: Defines a project directly inside
projectsviadefineInlineProjectwithout creating a separate file. - Nested projects: Sub-project configs can declare their own
projectsarray.
Root configuration
When the root config defines projects, the root directory itself is no longer treated as a test project—the root config only supplies projects and global configuration.
To also run tests in the root directory, add an inline project for it inside projects:
Global configuration
The following options are global and cannot be set per project. Configure them in the root config file, or override the options that expose a CLI flag (such as --reporters, --pool, --isolate, --coverage, --bail, or --teardownTimeout) from the command line:
reporters: Global reporters configuration.pool: Worker pool configuration.isolate: Environment isolation toggle.coverage: Code coverage configuration.bail: Failure threshold to stop the run.teardownTimeout: Process exit timeout forrstest run.resolveSnapshotPath: Snapshot file path resolver (config-only).onConsoleLog: Console log filter (config-only).output.distPath: Global output directory path (config-only).
Project configuration
Define project configuration
A project config supports most Rstest options, excluding global configuration.
Use defineInlineProject for inline objects inside any projects array (including nested projects), and defineProject for the top-level export of a project config file.
defineProjectaccepts an object or a sync/async factory function (() => .../async () => ...), and can omitname(Rstest infers it following the name rules).defineInlineProjectrequiresnameon every inline project item.
Share configuration
Project configs do not inherit options from the root config—only projects and global configuration in the root config apply across the run.
To share common settings across sub-projects, extract a shared config and combine it with mergeProjectConfig or mergeRstestConfig:
CLI options (such as --testTimeout, --testEnvironment, or --globals) override matching fields across all projects.
Nested projects
Sub-project config files can define their own projects array instead of declaring every variant in the root config.
For example, split packages/pkg-a into separate Node.js and jsdom projects:
Projects in browser mode
Each Browser Mode project compiles and runs with its own build configuration, so projects with different stacks or plugins can run in the same Rstest process.
Currently 'playwright' is the only supported provider. Within a run, you can target different browsers across projects (via browser.instances), open multiple headed debug windows or mix headed and headless instances in both run and watch, or mix Browser Mode projects with testEnvironment: 'node' or 'jsdom' projects, subject to these constraints:
- Unique reported project names: Multi-browser projects report as
<project> (<browser>), which must not collide with another project'sname; see Multi-browser reporting. - V8 coverage requires Chromium: When
coverage.provideris'v8', every selected browser must be Chromium; see Launch rules.
Inspect configuration
To inspect the final resolved configuration for each project, enable debug mode with DEBUG=rstest. Rstest writes the resolved Rstest and Rsbuild configs to the output directory.
Filtering projects
Use --project to run specific projects by name or glob pattern, or pass file filters to select files across projects. See Filtering tests for details.