storybook

Write and review React Storybook stories and colocated tests against typed SDK mocks and an integration harness.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill storybook-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: storybook
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/storybook
Command: npx skills add https://github.com/gabriellst/codm --skill storybook-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Frontend tests often drift into inconsistent shapes: connected components get stripped into presentational shells, mocks are hand-written and untyped, and sibling test files re-prove what a story's play function already covers. This Skill enforces a single canon for writing and reviewing every React frontend test — stories, colocated tests, and the integration harness they run against. ## Core Features & Use Cases - Dumb vs connected decision framework: Story presentational components with plain StoryObj args, and story data-owning components as-is using parameters.route, parameters.stores, and typed MSW helpers (mockQuery, loadingQuery, errorQuery, mockMutation, mockSession) keyed off SDK query options. - Story-as-fixture testing: Run stories in bun test via composeStories, with three sanctioned sibling lanes (*.services.test.tsx for a real gateway subprocess, harness-backed .test.tsx, and a documented reduced lane) that each prove a different boundary. - Integration harness by default: Assert real backend behavior through useIntegrationBackend() and mountRouter, with architecture rails that fail any test mounting RouterProvider without router.load() or stubbing globalThis.fetch. - Use Case: When adding a *.stories.tsx for a dashboard section that reads route search params and SDK queries, declare connected({ route: { id } }) parameters and typed DeepPartial mocks, then verify with tsc, storybook:build, and bun test. ## Quick Start Ask the agent to write a Storybook story and colocated test for a connected React component following the storybook skill's registry patterns.

Frequently Asked Questions about storybook

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

FAQPage Schema
How do I write a Storybook story for a connected React component?

Story the real component as-is without stripping its data layer. Declare parameters via connected({ route: { id } }) so the decorator synthesizes the router, and add typed MSW handlers like mockQuery(getXQueryOptions(p), response) built from SDK query options.

How do I mock SDK query responses in Storybook stories?

Use the typed helpers mockQuery, loadingQuery, errorQuery, mockMutation, and mockSession keyed off the SDK's getXQueryOptions. Responses are DeepPartial of the SDK response type with enum consts, so mocks stay type-checked without casts.

Does MSW intercept network requests under bun test?

No, MSW does not intercept under bun — this was measured, not assumed. The service worker API is absent under bun/happy-dom and the node interceptor does not hook node:http, so behavior assertions must use the integration harness instead.

When should a component have both a story and a test file?

Only when the test proves a different boundary than the story's play function. Sanctioned lanes are a *.services.test.tsx against a real gateway subprocess, a harness-backed .test.tsx for real backend behavior, or a documented reduced lane — never a re-proof of the same case.

Why does my React test render an empty RouterProvider?

The router was not loaded before the first render. Use mountRouter from tests/support, which calls router.load() and provides a settled() predicate poller; an architecture rail fails any test that mounts RouterProvider without it.

What verification steps should frontend tests pass?

Run bun x tsc --noEmit for type safety, bun run storybook:build to confirm every story compiles, and bun test for colocated tests, composeStories play functions, the stories smoke test, and the two architecture rails.