play function
A function on a Storybook story that runs after it renders, simulating user actions and asserting on the result.
In more detail
A play function might click a button with userEvent and check that a callback fired. Storybook's test runner runs every play function as an interaction test.
Related terms
- interaction test — A test that simulates a user clicking, typing or pressing keys and checks the component responds correctly.
- story — In Storybook, one saved example of a component in a particular state, such as Button in its primary or loading state.
- Testing Library — A family of testing libraries that render components and query them the way users find them, by role, label and text.
Taught in
- Storybook & Component Driven Development Workflows — Design Systems & Component Engineering