@actor-web/testing
Structural test helpers for the XState machines that drive machine-based actors — catch unreachable states and report transition coverage.
bash
pnpm add -D @actor-web/testinganalyzeStateMachine(machine)
ts
analyzeStateMachine(machine: AnyStateMachine): StateAnalysisResultStatic analysis: total states, reachable states, and the unreachable ones.
analyzeStateMachineWithGraph(machine)
ts
analyzeStateMachineWithGraph(machine: AnyStateMachine): Promise<StateAnalysisResult>Graph-based analysis (via @xstate/graph) for more precise reachability. Async.
assertNoUnreachableStates(machine, machineName?)
ts
assertNoUnreachableStates(machine: AnyStateMachine, machineName?: string): voidThrows if the machine has unreachable states — a one-line guard in a unit test.
generateCoverageReport(machine, machineName?)
ts
generateCoverageReport(machine: AnyStateMachine, machineName?: string): stringReturns a human-readable reachability/coverage report.
StateAnalysisResult
ts
interface StateAnalysisResult {
totalStates: number;
reachableStates: number;
unreachableStates: string[];
}