For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guide/start/agent-migrate.md.

Migrate to Rstest

Goal

Migrate the smallest runnable Jest, Vitest, or Playwright Test scope with minimal behavior change. Use documentation and types that match the installed Rstest version; use latest online docs only after the capability gate confirms they apply.

Workflow

  1. Detect the runner, environment, Rstack integration, and smallest runnable scope with https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/detect-test-framework.md.
  2. Run https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/dependency-install-gate.md before choosing Rstest, coverage, adapter, or plugin APIs.
  3. Before editing, record the exact command, Node and runner versions, environment, files/tests/skips/snapshots, and failures. Capture the pre-migration test manifest and follow https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/discovery-parity.md throughout the migration.
  4. For Jest read https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/jest-migration-deltas.md; for Vitest read https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/vitest-migration-deltas.md; for global APIs also read https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/global-api-migration.md; for a detected Playwright Test runner read https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/playwright-migration-deltas.md. Do not load the Playwright path for a browser-only request whose runner is not Playwright Test. Migrate scripts, config, and setup before editing test bodies; prefer adapter or Rsbuild/Rspack fixes over broad test rewrites.
  5. If config loading emits [MODULE_TYPELESS_PACKAGE_JSON], use https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/config-module-type.md. Do not suppress the warning or change the whole package module type without an audit.
  6. Get the migrated scope semantically green. Fix failures in this order: dependency skew, config/resolver, discovery, setup/environment/coverage, mocks/timers/snapshots, then test bodies.
  7. Compare the post-migration manifest and execution counts with the baseline. Classify every added, removed, skipped, or excluded test explicitly; do not call a run equivalent merely because it is green. For Jest snapshot migrations, also complete the snapshot cleanup and unchecked validation in https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/jest-migration-deltas.md.
  8. Remove temporary aliases, diagnostic hooks, and copied legacy workarounds that are no longer required. Keep only configuration proven necessary by behavior or measurement.
  9. If wall time, build, test runtime, logs, or memory materially regress, load and follow the rstest-debugging skill when available. Otherwise use the migration fallback in https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/performance-diagnosis.md, then read https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/dependency-bundling-performance.md and/or https://raw.githubusercontent.com/rstackjs/agent-skills/main/skills/migrate-to-rstest/references/mocked-module-build-graph.md according to the measured bottleneck. Change one variable at a time.
  10. After correctness and performance validation, remove only legacy files and dependencies owned by the migrated scope. Summarize behavior parity, discovery differences, unsupported fields, retained compatibility config, performance tradeoffs, and TODOs.

Guardrails

High-risk Rstest deltas