$npx -y skills add rstackjs/agent-skills --skill migrate-to-rstestMigrate Jest or Vitest projects to Rstest. Use when asked to move from Jest/Vitest to Rstest, replace jest/vi APIs with @rstest/core, translate config into rstest.config.ts, update scripts/coverage/setup/mocks/snapshots/projects, or diagnose migration failures caused by R
| 1 | # Migrate to Rstest |
| 2 | |
| 3 | ## Goal |
| 4 | |
| 5 | Migrate Jest/Vitest tests and config to Rstest with minimal behavior changes. Use the current Rstest migration docs for exact mappings; this skill adds scope, dependency, and cleanup guardrails. |
| 6 | |
| 7 | ## Workflow |
| 8 | |
| 9 | 1. Detect runner and scope (`references/detect-test-framework.md`). |
| 10 | 2. Run dependency/version gates (`references/dependency-install-gate.md`). |
| 11 | 3. Read only the needed deltas: Jest, Vitest, and/or global API replacement. |
| 12 | 4. Migrate scripts/config/setup before tests; prefer adapters or Rsbuild/Rspack config fixes before editing test bodies. |
| 13 | 5. Validate discovery/types/run, fixing failures in this order: dependency skew, config/resolver, setup/env/coverage, mocks/timers/snapshots, test bodies. |
| 14 | 6. After the scope is green, remove only scope-local legacy files and devDeps no remaining scope uses. |
| 15 | 7. Summarize changes, kept legacy files, unsupported fields, and TODOs. |
| 16 | |
| 17 | ## Guardrails |
| 18 | |
| 19 | - Keep the smallest viable scope; do not broaden a monorepo migration or bulk-rewrite tests when config/setup fixes are plausible. |
| 20 | - Do not change production behavior, assertions, test names, scenarios, or coverage thresholds to make migration pass. |
| 21 | - No `jest`/`vi` shims or aliases; rewrite call sites to Rstest APIs (`references/global-api-migration.md`). |
| 22 | - Do not silently drop unknown config fields; verify or report them as unsupported. |
| 23 | |
| 24 | ## High-risk Rstest deltas |
| 25 | |
| 26 | - `rstest` / `rstest run` is single-run; watch mode is `rstest --watch` or `rstest watch`. |
| 27 | - `globals` defaults to `false`; if globals remain, set `globals: true` and add `@rstest/core/globals` types. |
| 28 | - Rstest runs on Rsbuild/Rspack. Use `references/dependency-install-gate.md` for latest-only APIs, coverage providers, adapters, plugins, and toolchain-version fallbacks. |
| 29 | |
| 30 | ## Escalate before large edits |
| 31 | |
| 32 | If the next fix requires many test edits or production source changes, stop and report: why smaller fixes failed, options, risks, and the recommended path. |