What problem does it solve?
This Skill provides comprehensive strategies and patterns for effectively testing XState v5 state machines, ensuring the reliability and correctness of your application's state logic.
Core Features & Use Cases
- Actor Testing: Verify machine behavior by creating actors, sending events, and asserting snapshots.
- Pure Transition Testing: Test state transitions in isolation without creating actors, using
transition() and initialTransition().
- Mocking: Utilize
.provide() to mock actions, actors, and guards for controlled testing scenarios.
- Async Testing: Handle asynchronous operations with
waitFor, toPromise, and promise resolution patterns.
- Use Case: When developing a complex user authentication flow with XState, use this Skill to write robust tests that cover successful logins, error states, and session timeouts.
Quick Start
Use the xstate-testing skill to write unit tests for your XState v5 machines, focusing on behavior and transitions.