---
title: "David Khourshid"
description: "David Khourshid teaches state machines with XState and argues for model-based and property-based testing."
plain: "David Khourshid teaches state machines with XState and argues for model-based and property-based testing."
group: person
terms:
  - "David Khourshid"
  - "David K"
sources:
  - url: https://css-tricks.com/model-based-testing-in-react-with-state-machines/
    title: "Model-Based Testing in React with State Machines"
    publisher: "David Khourshid · CSS-Tricks"
    note: "State-machine testing article; used for David's model-based testing approach."
    accessed: "2026-10-01"
  - url: https://frontendmasters.com/courses/xstate-v2/testing/
    title: "Testing - State Machines in JavaScript with XState, v2 | Master.dev"
    publisher: "David Khourshid · Master.dev"
    note: "Testing lesson; used for the XState testing course reference."
    accessed: "2026-10-01"
  - url: https://stately.ai/docs/graph
    title: "Graph & Paths"
    publisher: "David Khourshid · Stately docs"
    note: "Path generation docs; used for createTestModel and getShortestPaths."
    accessed: "2026-10-01"
  - url: https://x.com/davidkpiano/status/2105670489091834297
    title: "David K 🎹 on X: \"@joelhooks I need to get you on the MBT/PBT train\" / X"
    publisher: "David Khourshid"
    note: "Public reply; used for David's invitation to adopt model and property testing."
    accessed: "2026-10-01"
  - url: https://x.com/davidkpiano/status/2119788094434038264
    title: 'David K 🎹 on X: "What is an implicit state machine?" / X'
    publisher: "David Khourshid"
    note: "Post of 2026-11-09; used for his description of implicit state machines."
    accessed: "2026-11-09"
---

# David Khourshid

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

New on /news: [Foldkit 0.171.0 requires result Message schemas](/news).

David Khourshid wrote [Model-Based Testing in React with State Machines](https://css-tricks.com/model-based-testing-in-react-with-state-machines/) for CSS-Tricks in 2019. It explains how to generate tests from a state machine instead of writing each case by hand.

In the testing lesson of his Frontend Masters course on XState, he describes a test model as "a state machine, and the state machine represents all of your given when then statements in a single state machine." He adds that model-based testing lets you "test any application whether they're using state machines or not." [Testing, State Machines in JavaScript with XState, v2](https://frontendmasters.com/courses/xstate-v2/testing/)

XState is a library for defining and running state machines.
It carries that idea in `xstate/graph` with `createTestModel` and `getShortestPaths`. [Graph & Paths](https://stately.ai/docs/graph)

On 2026-10-01 he told Joel, "I need to get you on the MBT/PBT train." [X](https://x.com/davidkpiano/status/2105670489091834297) MBT means model-based testing: compare the application with a model across action sequences.
PBT means property-based testing: check rules with generated inputs.
This repo uses both: see [model-based testing](/lore/model-based-testing) and [property-based testing](/lore/property-based-testing).

On 2026-11-09 he described implicit state machines. [X](https://x.com/davidkpiano/status/2119788094434038264) They are ad-hoc transition logic spread across a codebase. See [implicit state machines](/lore/implicit-state-machines) for his words and our worked example.

## Sources

1. [Model-Based Testing in React with State Machines](https://css-tricks.com/model-based-testing-in-react-with-state-machines/)
   David Khourshid · CSS-Tricks. State-machine testing article; used for David's model-based testing approach. Accessed 2026-10-01.

2. [Testing - State Machines in JavaScript with XState, v2 | Master.dev](https://frontendmasters.com/courses/xstate-v2/testing/)
   David Khourshid · Master.dev. Testing lesson; used for the XState testing course reference. Accessed 2026-10-01.

3. [Graph & Paths](https://stately.ai/docs/graph)
   David Khourshid · Stately docs. Path generation docs; used for createTestModel and getShortestPaths. Accessed 2026-10-01.

4. [David K 🎹 on X: "@joelhooks I need to get you on the MBT/PBT train" / X](https://x.com/davidkpiano/status/2105670489091834297)
   David Khourshid. Public reply; used for David's invitation to adopt model and property testing. Accessed 2026-10-01.

5. [David K 🎹 on X: "What is an implicit state machine?" / X](https://x.com/davidkpiano/status/2119788094434038264)
   David Khourshid. Post of 2026-11-09; used for his description of implicit state machines. Accessed 2026-11-09.

## Lore on this page

- [Model-based testing](/lore/model-based-testing)
- [Property-based testing](/lore/property-based-testing)
- [Implicit state machines](/lore/implicit-state-machines)

## Linked from

- Agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms.txt)

- Change log → What changed in the files served here, newest first. → [Read page](https://ratstack.sh/log)

- Effect 4 study: September 2026 → Dated Effect 4 source studies from September 2026; current versions live in pins.md. → [Read page](https://ratstack.sh/resources/effect-4-reference-projects)

- Full agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms-full.txt)

- Implicit state machines → Every app runs state machines; the risky ones are scattered across flags, conditions and loops where nobody can list the transitions. → [Read page](https://ratstack.sh/lore/implicit-state-machines)

- Model-based testing → Describe what a system should do as a small model, generate action sequences, and check the real system against the model. → [Read page](https://ratstack.sh/lore/model-based-testing)

- Rat Stack lore | rat-stack → Short, source-grounded notes on the ideas and decisions behind rat-stack. → [Read page](https://ratstack.sh/lore)

- rat-stack → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/)

- Source change history (log.md) → The generated change log as Markdown. → [Read page](https://ratstack.sh/log.md)
