Model-based testing in XState
Learn all about when and how to use model-based testing with XState.
Model-based testing
Adopting model-based testing can lead to self-documenting, easy-to-maintain tests which are far more DRY than regular tests.
When to use XState Test
When you discover a new tool, it’s tempting to use that tool for everything. Model-based testing is good for many use cases but not for all use cases.
Quickstart
How to get started quickly with model-based testing using XState and @xstate/test.
Test paths
@xstate/test generates test paths that it walks through to execute your tests. Knowing how these paths are generated will make your tests more predictable.
Assertions
If you’ve done testing before, you might be familiar with the setup, then assert pattern for writing tests:
Event cases
Sometimes you want to test your system with a variety of different values. For example, you might be testing a payment system where you can pay with many different currencies, and you need to ensure that GBP, EUR and USD all work.
Jest in XState Test
Integrating with Jest is simple with @xstate/test.
Vitest in XState Test
Integrating with Vitest is simple with @xstate/test.
Cypress in XState Test
Integrating with Cypress is simple with @xstate/test.
Playwright in XState Test
Integrating with Playwright is simple with @xstate/test.