close
logo
Rstest
Guide
Config
API
English
简体中文
Guide
Config
API
English
简体中文
logo
Rstest
Overview

Test Configurations

root
name
include
exclude
setupFiles
projects
update
globals
passWithNoTests
includeSource
testNamePattern
env
retry
testTimeout
hookTimeout
maxConcurrency
pool
isolate
testEnvironment
clearMocks
resetMocks
restoreMocks
unstubEnvs
unstubGlobals
coverage
reporters
hideSkippedTests
slowTestThreshold
snapshotFormat
resolveSnapshotPath
printConsoleTrace
onConsoleLog
disableConsoleIntercept

Build Configurations

plugins
source
output
resolve
tools
dev
performance
📝 Edit this page on GitHub
Previous PagesetupFiles
Next Pageupdate

#projects

  • Type:
type ProjectConfig = Omit<
  RstestConfig,
  'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage'
>;

type Projects = (string | ProjectConfig)[];
  • Default: [<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 apps 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',
    },
  ],
});

#Configuration notes

  • Project configuration does not inherit root configuration. If there is shared configuration between your sub-projects, you can extract the shared configuration and import it in the sub-project.
  • Some root-level options such as reporters, pool, and isolate are not valid in a project configuration.
  • projects does not support nesting.
packages/pkg-a/rstest.config.ts
import { defineConfig } from '@rstest/core';
import sharedConfig from '../shared/rstest.config';

export default defineConfig({
  ...sharedConfig,
});

#Inline configuration

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