Write model-based tests with @xstate/test 2.0 beta, replace end-to-end tests with model-based tests without losing coverage, and visualize the model in Stately. Use for model-based testing, @xstate/test, generating tests from a state machine, testing every path, replacing Playwright, Cypress, Vitest, or Jest end-to-end tests with a model, coverage parity, or migrating from @xstate/test 0.x or 1.0 beta.
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Medium
Suggest reviewing before use
The model-based-testing skill teaches coding agents to write model-based tests
with @xstate/test 2.0 beta. The agent models what a user can see and do as an
XState machine, generates test paths from it, and shows the model and its
coverage in Stately. It can also replace existing end-to-end tests with model
tests while tracking each legacy test in a parity ledger, so no assertion is
lost.
npx skills add statelyai/skills --skill model-based-testingThe Codex stately plugin also includes this skill. The Claude Code plugin
does not. See Install.
Write a model-based test for the login page.The agent writes the model from requirements and existing tests, shows it in Stately for you to confirm, then writes the system under test and gates on transition and state node coverage with no unknown entries.
Replace our Playwright tests for checkout with a model-based test without losing coverage.The agent inventories the existing tests with each runner, records every test
in a ledger as mapped, residual, or dropped, and replays each mapped test
against the model. It deletes a legacy test only after the parity check passes
and every project has a passing replay and negative controls for the mapped
assertions. Use runtime-expanded cases when a listing retains parameter
placeholders. Tests the model cannot express, such as screenshots or accessibility
audits, stay as they are.
node <skill-dir>/scripts/coverage-viewer.mjs --machine <model file>The viewer serves the model at http://127.0.0.1:5173 and colors covered state
nodes and transitions green and uncovered ones red as tests report runs.
@xstate/test@beta and xstate@beta (@xstate/test 2.x requires xstate
6). fast-check for property tests.@statelyai/sdk for the coverage viewer/mcp
and sign in to stately. In Codex, run codex mcp login stately.| Path | Contents |
|---|---|
SKILL.md | Setup, model test, replacement, and reporting workflow |
references/parity-ledger.md | Ledger format and templates for replacing end-to-end tests |
scripts/parity-check.mjs | Checks the ledger against inventories and execution evidence |
scripts/coverage-viewer.mjs | Local server that shows live coverage on the model |
scripts/parity-check.test.mjs | Regression tests for the parity checker |
evals/ | Evaluation prompts |