CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

statelyai/model-based-testing

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.

Quality

100%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

README.md

Model-based testing skill

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.

Install

npx skills add statelyai/skills --skill model-based-testing

The Codex stately plugin also includes this skill. The Claude Code plugin does not. See Install.

Use

Write a model test

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 end-to-end tests

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.

Watch coverage

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.

Requirements

  • @xstate/test@beta and xstate@beta (@xstate/test 2.x requires xstate 6). fast-check for property tests.
  • @statelyai/sdk for the coverage viewer
  • A Stately MCP connection to show models in Stately. In Claude Code, run /mcp and sign in to stately. In Codex, run codex mcp login stately.

Contents

PathContents
SKILL.mdSetup, model test, replacement, and reporting workflow
references/parity-ledger.mdLedger format and templates for replacing end-to-end tests
scripts/parity-check.mjsChecks the ledger against inventories and execution evidence
scripts/coverage-viewer.mjsLocal server that shows live coverage on the model
scripts/parity-check.test.mjsRegression tests for the parity checker
evals/Evaluation prompts

Related skills

  • xstate-v6 for writing the model machine
  • stately for viewing and checking models in Stately

LICENSE

README.md

SKILL.md

tile.json