close

projects

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

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.

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

More information about projects can be found in Test projects.

Projects in browser mode

When you use projects with Browser Mode, each project compiles and executes with its own build config, which lets you keep different stacks or build setups in one repository.

In the same run, browser launch options must stay consistent across browser projects:

  • provider
  • browser
  • headless
  • port
  • strictPort

So mixing multiple providers, or multiple browser types, in one run is not supported yet.

rstest.config.ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  projects: ['./project-b/rstest.config.ts', './project-a/rstest.config.ts'],
});
project-a/rstest.config.ts
import { pluginReact } from '@rsbuild/plugin-react';
import { defineConfig } from '@rstest/core';

export default defineConfig({
  name: 'project-a',
  plugins: [pluginReact()],
  include: ['tests/**/*.test.tsx'],
  browser: {
    enabled: true,
    provider: 'playwright',
  },
});
project-b/rstest.config.ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  name: 'project-b',
  include: ['tests/**/*.test.ts'],
  browser: {
    enabled: true,
    provider: 'playwright',
  },
});

You can still mix Browser Mode projects with testEnvironment: 'node'/'jsdom' projects in one projects list, and results will be merged in the final report.