Follow these steps in order to add Rstest to the current project. Read the repository first. Make the smallest correct change.
Fetch a linked doc page only after choosing that branch. Do not fetch docs for branches you did not select.
@rstest/core. Config file is always rstest.config.ts (even in JS projects).react or vue appears in dependencies.test scripts unless migration is clearly intended — add "test:unit": "rstest" or similar instead.include (https://rstest.rs/config/test/include.md) to target only Rstest's own tests so it does not discover tests written for another runner.@rstest/core or rstest.config.ts already exists, extend the existing setup minimally instead of recreating it.test('placeholder', () => {})). A real verification test is fine when no tests exist — see Step 8.Before editing anything, determine:
packageManager field in root package.json)pnpm-workspace.yaml, workspaces in package.json, turbo.json, nx.json)@rstest/core, rstest.config.ts, scripts)Choose in this order:
Note: deps, config, and scripts may live in different places. Determine separately:
Now inspect the owning package:
.ts/.tsx/.mts vs .js/.jsx/.mjs)rsbuild.config.*, rslib.config.*, or neither)Determine from the owning package's actual source/test file extensions first. Use tsconfig.json or typescript dep only as a tiebreaker.
.ts / .tsx test files..js / .jsx test files.An adapter auto-inherits plugins, aliases, and build config. If using an adapter, follow that guide first — only fetch a framework guide if the adapter guide does not already cover the required setup.
rsbuild.config.* or @rsbuild/core dep) → follow https://rstest.rs/guide/integration/rsbuild.mdrslib.config.* or @rslib/core dep) → follow https://rstest.rs/guide/integration/rslib.mdWhen using an adapter you may still need to set testEnvironment or browser — the adapter does not decide those.
Decide based on what the tests actually need, not solely from framework deps in package.json. See https://rstest.rs/config/test/test-environment.md for all options.
Omit testEnvironment. No extra deps. If not using an adapter and no other options are needed:
import { defineConfig } from '@rstest/core';
export default defineConfig({});
happy-dom / jsdomUse for tests that render components or rely on DOM APIs.
jsdom or happy-dom, follow that choice.happy-dom (lighter).Choose only when tests explicitly require Canvas, WebGL, CSS computed styles, Web Workers, or cross-browser testing. This is opt-in, not a default escalation. Vue Browser Mode is not yet supported. See https://rstest.rs/config/test/browser.md for all options.
→ Follow https://rstest.rs/guide/browser-testing/getting-started.md → For React component testing in browser, also follow https://rstest.rs/guide/browser-testing/framework-guides.md
Use the repo's existing package manager (pnpm add -D, npm i -D, yarn add -D, bun add -d) based on the lockfile. Fall back to the packageManager field in root package.json if no lockfile exists. Install only packages justified in previous steps.
Keep it minimal — include only options justified by detection. → See https://rstest.rs/guide/basic/configure-rstest.md only if the selected guide above does not fully specify the config.
Config examples are in the guide pages linked in Steps 4–5. Do not copy examples blindly.
If migration is intended, you should already be following the migration guide — skip this step.
"test": "rstest".test exists (Jest/Vitest) → add "test:unit": "rstest" or similar."test:browser" script.Only if no tests exist and verification is needed:
*.test.* vs *.spec.*), placement, and language.Run the test command from wherever the test script lives. If it fails, read the error and fix — do not leave a broken setup. If no tests exist and you skipped Step 9, confirm the setup is valid (config loads, rstest --passWithNoTests or equivalent succeeds).