mcpField
S
storybook-stories

storybook-stories

github.com/oakossTesting & quality20117 installsUpdated 11w ago
Repository

About storybook-stories

A Storybook guidance skill for frontend developers documenting and testing UI components in isolation. It focuses on CSF3 stories, interaction tests, accessibility checks, and visual regression workflows.

Key features

  1. 01CSF3 story patterns
  2. 02Interactive tests with play functions
  3. 03Accessible component checks
  4. 04Autodocs and controls
  5. 05Chromatic visual snapshots

Use cases

  1. 01Document components with live examples
  2. 02Test component interactions
  3. 03Validate accessible labels
  4. 04Investigate visual regression failures

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/oakoss/agent-skills --skill storybook-stories

After installing, type/storybook-storiesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
component-documentation.md
interaction-tests.md
story-writing.md
visual-testing.md

Details

From the project README

Storybook Stories

Overview

Storybook is a frontend workshop for building UI components in isolation. Stories are written in Component Story Format 3 (CSF3), which uses object syntax with args for type-safe component documentation and testing.

When to use: Component documentation with live examples, interaction testing with play functions, visual regression testing, accessibility validation, design system maintenance, isolated component development.

When NOT to use: End-to-end testing (use Playwright/Cypress), API integration testing (use Vitest/Jest), full application testing (use browser automation), performance testing (use Lighthouse/WebPageTest).

Quick Reference

PatternAPIKey Points
Basic storyexport const Default: Story = { args }Use args for simple single components
Complex storyexport const Example: Story = { render }Use render for multi-component layouts
Meta configurationconst meta = { component, args } satisfies MetaDefine defaults and argTypes
Interaction testplay: async ({ canvas, userEvent, args })canvas and userEvent provided directly
User interactionawait userEvent.click(element)Always await userEvent methods
Query elementscanvas.getByRole('button')Prefer getByRole over other queries
Assertionsawait expect(args.onPress).toHaveBeenCalled()Use storybook/test assertions
beforeEach hookbeforeEach: async ({ args }) => {}Setup mocks before story renders
Play compositionawait OtherStory.play?.(context)Reuse setup across stories
Autodocstags: ['autodocs']Enable automatic documentation
Controls customizationargTypes: { variant: { control: 'select' } }Configure control panel
Decoratorsdecorators: [withTheme]Add wrappers or context providers
Parametersparameters: { layout: 'centered' }Configure addon behavior per story
Chromatic snapshotparameters: { chromatic: { delay: 300 } }Control visual regression captures
Disable snapshotparameters: { chromatic: { disableSnapshot: true } }Skip story in visual tests
A11y testingawait expect(button).toHaveAccessibleName()Validate accessible labels

Common Mistakes

MistakeCorrect Pattern
Using args with multi-component layoutsUse render for complex compositions
Not awaiting userEvent methodsAlways await: await userEvent.click(button)
Using within(canvasElement) manuallyDestructure canvas from play context directly
Using getByTestId firstPrefer getByRole, getByLabelText, getByText
Missing default args at meta levelAdd args to meta to prevent placeholder controls
Exposing non-serializable propsDisable className, ref, style in argTypes
Not composing play functionsReuse setup with await BaseStory.play?.(context)
Forgetting to mock callbacksUse fn() for event handlers: args: { onPress: fn() }
Missing accessible names for icon buttonsAdd aria-label or use aria-labelledby
Not scoping queries for portal contentUse within(canvasElement.ownerDocument.body)
Using boolean && for conditional renderingUse ternary in stories for consistent snapshots
Not waiting for animationsWrap assertions in waitFor for async state

Common Fixes

ProblemSolution
Controls show placeholdersAdd args at meta level with default values
Serialization errorDisable className, ref, style in argTypes
Portal element not foundSearch body instead of canvas
Animation timing issuesWrap assertions in waitFor
Multiple buttons foundAdd { name: '...' } to getByRole
A11y test failingAdd label prop or aria-label

Delegation

  • Story structure review: Use code-reviewer skill for CSF3 pattern validation
  • Accessibility audit: Use Explore agent to discover ARIA patterns across stories
  • Visual regression analysis: Use Task agent to investigate Chromatic failures

References

Comments

Markdown supported