root

  • Type: string
  • Default: process.cwd()
  • CLI: -r=<path>, --root=<path>

Specify the project root directory. Can be an absolute path, or a path relative to process.cwd(). root determines the starting point for loading configuration files, searching test files, etc.

Using <rootDir> in any path-based configuration settings will reference this value.

rstest.config.ts
import { defineConfig } from 'rstest';

export default defineConfig({
  setupFiles: ['<rootDir>/setup.js'],
  include: ['<rootDir>/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
  root: './my-project',
});