Rstest setup — agent execution prompt

Set up Rstest in a project that doesn't have a test runner configured yet. Pick the target, detect what it needs, install, verify.

Prerequisite check

If the target already has Jest or Vitest configured (any of the signals below), STOP this prompt and fetch https://rstest.rs/guide/start/agent-migrate.md instead — migration has its own flow:

Otherwise, continue below.

Section 1 — pick the target

All work in this prompt happens inside a single target package.

Single-package repo → the target is the repo root.

Monorepo (signals: pnpm-workspace.yaml, workspaces in root package.json, turbo.json, nx.json):

Section 2 — detect

All detection below runs inside the target.

2.1 Language

Determine from the target's actual source/test file extensions first. Only fall back to tsconfig.json presence or typescript in deps when extensions are mixed or absent.

2.2 Build tool (→ pick adapter)

An adapter auto-inherits plugins, aliases, and build config. Even with an adapter you still need to decide testEnvironment or browser mode from 2.3 — adapters do not decide those. If 2.3 picks Browser Mode, that takes precedence over adapters.

2.3 Test environment

Decide based on what the target's tests actually need, not solely from framework deps in package.json. See https://rstest.rs/config/test/test-environment.md for all options.

A. No DOM APIs needed → node (default)

Omit testEnvironment. No extra deps. If not using an adapter and no other options are needed:

import { defineConfig } from '@rstest/core';
export default defineConfig({});

B. DOM APIs needed, simulated DOM is sufficient → happy-dom / jsdom

Pick B only if any of these hold for the target's source/test code:

If none of the above hold, stay on A. Seeing react in dependencies alone is not sufficient.

C. Real browser behavior needed → browser mode (experimental)

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.

STOP this prompt. Fetch https://rstest.rs/guide/browser-testing/getting-started.md and follow it end-to-end — Browser Mode has its own setup flow that replaces Sections 3–4. For React component testing in browser, also fetch https://rstest.rs/guide/browser-testing/framework-guides.md.

Section 3 — install and configure

All edits are scoped to the target package. If the target already has @rstest/core, rstest.config.ts, or an rstest script, extend it minimally instead of recreating it.

Section 4 — verify