storybook-play-functions

Automate Storybook interaction tests with userEvent and waitFor assertions.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill storybook-play-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: storybook-play-functions
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-storybook/skills/storybook-play-functions
Command: npx skills add https://github.com/TheBushidoCollective/han --skill storybook-play-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill enables you to write automated interaction tests directly within your Storybook stories using play functions, verifying component behavior and simulating user actions. It automates the testing of UI interactions.

Core Features & Use Cases

  • Simulate User Interactions: Use userEvent to mimic realistic user behavior like typing, clicking, and tabbing within your stories.
  • Asynchronous Testing: Test complex async flows and state changes using waitFor and expect from Testing Library.
  • Error State Validation: Verify how components handle invalid inputs and display error messages, ensuring robust user experiences.
  • Use Case: For a login form component, use a play function to simulate a user typing an invalid email, then a valid email, and finally clicking submit. This automatically tests the form's validation, submission, and success/error states, ensuring it works as expected without manual clicks.

Quick Start

Use the storybook-play-functions skill to write a play function for a LoginForm story that types an email and password, then clicks the submit button.

Frequently Asked Questions about storybook-play-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate UI interaction testing in Storybook?

Automate UI interaction testing in Storybook using play functions with userEvent to simulate user actions like typing and clicking, combined with Testing Library queries and waitFor assertions to validate component behavior and state changes.

Can I test form validation and async state changes within Storybook stories?

Yes. Play functions let you simulate user input, trigger validation logic, and use waitFor to assert on asynchronous updates, enabling end-to-end interaction testing directly in your stories without leaving Storybook.

What's the best way to verify component error states and edge cases?

Use play functions to simulate invalid inputs and trigger error conditions, then use Testing Library queries to assert error messages and UI changes appear correctly, ensuring components handle edge cases robustly.

Do I need Testing Library to write Storybook play functions?

Yes. Play functions rely on Testing Library utilities—within, getBy*, queryBy*—to query DOM elements and userEvent to simulate interactions. Testing Library is the standard approach for interaction testing in Storybook.

How do play functions differ from manual Storybook testing?

Play functions automate repetitive interaction sequences—typing, clicking, waiting for async updates—so you verify component behavior consistently without manual browser clicks, enabling continuous validation across component changes.

What scenarios work best with Storybook play functions?

Play functions excel at testing user workflows: form submissions with validation, multi-step interactions, error recovery, async loading states, and conditional rendering triggered by user input—scenarios requiring scripted sequences of actions.