> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# projects

- **类型：**

```ts
type ProjectConfig = Omit<
  RstestConfig,
  'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'bail'
>;

type Projects = (string | ProjectConfig)[];
```

- **默认值：** `[<rootDir>]`

定义多个测试项目，可以是一个目录、配置文件或 glob 模式，也可以是一个对象。 Rstest 将会按照各个项目定义的配置运行对应的测试，所有项目的测试结果将会合并展示。

```ts name='rstest.config.ts'
import { defineConfig, defineInlineProject } 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
    defineInlineProject({
      name: 'node',
      include: ['tests/node/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
    }),
    defineInlineProject({
      name: 'react',
      include: ['tests/react/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
      testEnvironment: 'jsdom',
    }),
  ],
});
```

任何 `projects` 数组里的对象项，包括嵌套 `projects`，都建议搭配 `defineInlineProject()`。`defineProject()` 只用于项目配置文件的顶层导出。

`defineProject()` 允许顶层导出的 project 省略 `name`，再由 Rstest 按 [name](/zh/config/test/name.md) 配置项的规则自动推导。`defineInlineProject()` 则要求每个 inline project 都显式提供 `name`。

更多关于项目配置的信息，请参考[多项目测试](/zh/guide/basic/projects.md)。
