| name | migrate-to-rstest |
| description | Migrate 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 config-loading warnings, migration failures, and memory/performance regressions caused by Rstest's Rsbuild/Rspack execution model, DOM dependency bundling, runtime-mocked module build graphs, or version skew. |
Migrate to Rstest
Goal
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.
Workflow
- Detect runner and scope (
references/detect-test-framework.md).
- Run dependency/version gates (
references/dependency-install-gate.md).
- Read only the needed deltas: Jest, Vitest, and/or global API replacement.
- Migrate scripts/config/setup before tests; prefer adapters or Rsbuild/Rspack config fixes before editing test bodies.
- If config loading emits
[MODULE_TYPELESS_PACKAGE_JSON], declare the config's module format with references/config-module-type.md; do not suppress the warning or change the whole package's module type without an audit.
- Validate discovery/types/run, fixing failures in this order: dependency skew, config/resolver, setup/env/coverage, mocks/timers/snapshots, test bodies.
- If a
jsdom, happy-dom, or other browser-like environment has much higher peak RSS or build cost than Jest/Vitest, compare equivalent runs and tune dependency bundling with references/dom-dependency-bundling.md before changing worker counts or test code.
- If a test fully mocks a heavy module but Rspack still compiles that module's source graph, run the narrow
output.externals experiment in .