projects

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

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