migrate-to-rstest — скилл для Claude Code: миграция тестов на Rstest
Переносит тесты из Jest, Vitest или Playwright Test в Rstest, сохраняя обнаружение, ассерты, моки, снапшоты и покрытие. Пригодится, когда надо переехать без переписывания сценариев.
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a claude-codeЧто делает migrate-to-rstest
Скилл ведёт миграцию по шагам. Сначала определяет раннер, окружение и минимальный запускаемый объём, затем проверяет установленные зависимости и только после этого трогает тесты. Порядок жёсткий: скрипты, конфиг и setup — раньше, чем тела тестов.
Внутри — набор reference-файлов под конкретные исходники: отдельные инструкции для Jest, Vitest, Playwright Test, глобальных API и ошибки [MODULE_TYPELESS_PACKAGE_JSON]. Есть и гейт зависимостей, который не даёт выбрать неподходящий API Rstest до проверки установленной версии.
Ограничения стоит знать заранее: rstest run — однократный запуск, watch-режим включается отдельной командой rstest --watch. Глобальные API по умолчанию выключены, для них нужен globals: true и типы @rstest/core/globals. А rs.mock() — замена в рантайме, сам по себе он не вырезает реальный граф модулей из сборки. Скилл требует, чтобы прежний раннер оставался в проекте, пока Rstest не даст зелёный прогон.
После миграции скилл сверяет манифесты тестов до и после: каждый добавленный, удалённый или пропущенный тест классифицируется явно. Зелёный прогон не считается эквивалентным сам по себе. Снапшоты Jest проходят отдельную чистку и проверку unchecked.
Какие задачи решает
- перенести тесты из Jest без потери обнаружения и ассертов
- сохранить моки, снапшоты и покрытие при переезде на Rstest
- понять, какие поля конфига Rstest не поддерживает
- проверить, что число тестов до и после миграции совпадает
- найти причину регресса производительности после переезда
Примеры запросов агенту
- перенеси тесты этого проекта из Vitest в Rstest
- смигрируй только этот тестовый файл из Jest, остальное не трогай
- после миграции сравни манифест тестов с базовым и покажи расхождения
Как установить migrate-to-rstest
1Через Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a claude-code2Вручную: положить файлы
~/.claude/skills/migrate-to-rstest/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/migrate-to-rstest/
1Через Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a codex2Вручную: положить файлы
.agents/skills/migrate-to-rstest/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a cursor2Вручную: положить файлы
.cursor/skills/migrate-to-rstest/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install rstackjs/agent-skills migrate-to-rstest2Вручную: положить файлы
.github/skills/migrate-to-rstest/SKILL.md1Через Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a gemini-cli2Командой платформы
gemini skills install https://github.com/rstackjs/agent-skills --path skills/migrate-to-rstestВручную: положить файлы
.devin/skills/migrate-to-rstest/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о migrate-to-rstest
Как установить migrate-to-rstest в Claude Code?
Выполни npx skills add rstackjs/agent-skills --skill migrate-to-rstest -a claude-code. Скилл появится в ~/.claude/skills/migrate-to-rstest/SKILL.md.
Что делает migrate-to-rstest?
Переносит минимальный запускаемый объём тестов из Jest, Vitest или Playwright Test в Rstest. Сохраняет обнаружение тестов, ассерты, моки, снапшоты и покрытие, а после миграции сверяет манифест с базовым.
Почему rs.mock() не убирает реальный модуль?
rs.mock() — это замена в рантайме, а Rstest собирает проект перед запуском тестов. Реальный модуль всё равно попадёт в граф сборки, если его не вырезать на уровне конфигурации.
Исходный текст
SKILL.md · MIT
--- name: migrate-to-rstest description: Migrate Jest, Vitest, or Playwright Test to Rstest while preserving test discovery, assertions, mocks, snapshots, and coverage. --- <!-- cspell:words TYPELESS --> # 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 `references/detect-test-framework.md`. 2. Run `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 `references/discovery-parity.md` throughout the migration. 4. For Jest read `references/jest-migration-deltas.md`; for Vitest read `references/vitest-migration-deltas.md`; for global APIs also read `references/global-api-migration.md`; for a detected Playwright Test runner read `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 `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 `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 `references/performance-diagnosis.md`, then read `references/dependency-bundling-performance.md` and/or `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 - Keep the smallest viable scope. Do not broaden a monorepo migration because scopes share a lockfile. - Do not change production behavior, assertions, test names, scenarios, coverage thresholds, or ignore directives to make migration pass. - Do not introduce `jest`/`vi` shims or aliases; rewrite call sites with `references/global-api-migration.md`. - Do not silently drop unknown config fields or historical excludes. Verify, replace, or report each one. - Do not compare performance across different test manifests, Node versions, coverage modes, cache states, or worker settings. - Keep the previous runner until Rstest is green. Use a local Rstest checkout only for labeled diagnostics, then validate the final result with the project's installed dependency. - Escalate before many test edits or any production-source change: report why smaller config/setup fixes failed, options, risks, and the recommended path. ## High-risk Rstest deltas - `rstest` / `rstest run` is single-run; watch mode is `rstest --watch` or `rstest watch`. - `globals` defaults to `false`; preserving global APIs requires `globals: true` and `@rstest/core/globals` types. - Rstest builds before tests run. `rs.mock()` is runtime replacement and does not by itself prune the real module graph. - Dependency bundling trades compiler work for runtime Node loading. Neither “bundle all” nor “externalize all” is universally faster; measure a representative file and the full scope. - An externalized runtime mock must match the exact request and module format. A config-wide external is unsafe when any test needs the real module.
© rstackjs · MIT · rstackjs/agent-skills