Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

storybook-testing故事书测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

1,505

周安装

64

GitHub Stars

160

下载量

527
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:storybook-testing(故事书测试)
来源仓库:https://github.com/yonatangross/orchestkit
仓库路径:skills/storybook-testing
安装命令:
npx skills add https://github.com/yonatangross/orchestkit --skill storybook-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/yonatangross/orchestkit --skill storybook-testing

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合让 Agent 编写单元测试、端到端测试或根据日志定位问题。
  • 需结合项目测试框架和运行命令使用,确保测试逻辑真实有效。
  • 涉及浏览器或外部服务时,应区分模拟环境与生产环境。
  • storybook-testing 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Storybook Testing — Storybook 10

Overview

Storybook 10 unifies component testing into a single workflow: interaction tests via play() functions, visual regression via Chromatic TurboSnap, and accessibility audits via the a11y addon — all running through Vitest. Stories are executable test specifications, not just documentation.

What's new in Storybook 10 (vs 9):

  • ESM-only enforced — the single breaking change; Node 20.16+ / 22.19+ / 24+ required; 29% smaller install
  • Module automocking (sb.mock) — build-time module mocking, scoped per-project in preview.ts
  • CSF factories (React, preview)defineMaindefinePreviewpreview.meta()meta.story() chain
  • Essential addons in core — viewport, controls, interactions, actions no longer separate deps
  • Import path changes@storybook/teststorybook/test (old paths still work as aliases)
  • React Server Component story support — test RSC in isolation
  • Vitest 4 supportexperimental-addon-test renamed to addon-vitest

When to use this skill:

  • Writing component stories in CSF3 format with TypeScript
  • Setting up interaction tests with play() functions
  • Configuring Chromatic visual regression with TurboSnap
  • Using module automocking at the story level
  • Running accessibility tests in CI via the a11y addon
  • Generating living documentation with autodocs
  • Migrating from Storybook 9 to 10

Quick Reference

RuleImpactDescription
storybook-csf3-factoriesHIGHTypesafe CSF3 story factories with satisfies Meta
storybook-play-functionsCRITICALInteraction testing with play() and @storybook/test
storybook-vitest-integrationHIGHRun stories as Vitest tests via @storybook/addon-vitest
storybook-chromatic-turbosnapHIGHTurboSnap reduces snapshot cost 60-90%
storybook-sb-mockHIGHStory-level module mocking with sb.mock
storybook-a11y-testingCRITICALAutomated axe-core accessibility scans in CI
storybook-autodocsMEDIUMAuto-generated docs from stories

Storybook Testing Pyramid

         ┌──────────────┐
         │   Visual     │  Chromatic TurboSnap
         │  Regression  │  (snapshot diffs)
         ├──────────────┤
         │ Accessibility│  @storybook/addon-a11y
         │   (a11y)     │  (axe-core scans)
         ├──────────────┤
         │ Interaction  │  play() functions
         │   Tests      │  (@storybook/test)
         ├──────────────┤
         │  Unit Tests  │  Vitest + storybookTest
         │  (stories)   │  plugin
         └──────────────┘

Each layer catches different defects: unit tests validate logic, interaction tests verify user flows, a11y tests catch accessibility violations, and visual tests catch unintended UI regressions.


Quick Start

CSF3 Story with Play Function

// Button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react'
import { expect, fn, userEvent, within } from 'storybook/test'
import { Button } from './Button'

const meta = {
  component: Button,
  args: {
    onClick: fn(),
  },
} satisfies Meta<typeof Button>

export default meta
type Story = StoryObj<typeof meta>

export const Primary: Story = {
  args: {
    label: 'Click me',
    variant: 'primary',
  },
  play: async ({ canvasElement, args }) => {
    const canvas = within(canvasElement)
    const button = canvas.getByRole('button', { name: /click me/i })

    await userEvent.click(button)
    await expect(args.onClick).toHaveBeenCalledOnce()
    await expect(button).toHaveStyle({ backgroundColor: 'rgb(37, 99, 235)' })
  },
}

Vitest Configuration

// vitest.config.ts
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'
import { defineConfig } from 'vitest/config'

export default defineConfig({
  plugins: [storybookTest()],
  test: {
    setupFiles: ['./vitest.setup.ts'],
  },
})

Key Principles

  • Stories are tests. Every story with a play() function is an executable interaction test that runs in Vitest.
  • CSF3 + satisfies for type safety. Use satisfies Meta<typeof Component> for full type inference on args and play functions.
  • Module automocking (SB 10). Register sb.mock(import(...)) in .storybook/preview.ts, configure per-story with mocked() in beforeEach. Never use vi.mock in story files. No factory functions — sb.mock is build-time, not runtime.
  • TurboSnap for CI speed. Only snapshot stories affected by code changes — reduces Chromatic usage by 60-90%.
  • Accessibility is not optional. The a11y addon runs axe-core scans on every story and gates CI on violations.
  • Living documentation. Autodocs generates prop tables and usage examples directly from stories — no separate docs site needed.

Anti-Patterns (FORBIDDEN)

Anti-PatternWhy It FailsUse Instead
CSF2 Template.bind({})Deprecated, no type inference, will be removed in SB 11CSF3 object stories with satisfies
@storybook/test-runner packageDeprecated since Storybook 9@storybook/addon-vitest
vi.mock() in story filesLeaks between stories, breaks isolationRegister sb.mock(import(...)) in preview.ts, configure with mocked() in beforeEach
Full Chromatic snapshots on every PRExpensive and slowTurboSnap with onlyChanged: true
Manual accessibility checkingMisses violations, not repeatable@storybook/addon-a11y in CI pipeline
Separate documentation siteDrifts from actual component behaviorAutodocs with tags: ['autodocs']
Testing implementation detailsBrittle, breaks on refactorsTest user-visible behavior via play()
CJS imports in storiesESM-only since SB 9/10Use ESM imports, set "module": "ESNext" in tsconfig

Storybook MCP Integration (addon-mcp)

When @storybook/addon-mcp is installed, agents can run tests and preview stories via MCP instead of CLI. This enables the generate → test → self-heal loop.

MCP Tools for Testing

ToolPurpose
run-story-testsRun component + a11y tests via MCP, returns pass/fail + violation details
preview-storiesReturns preview URLs for visual verification in chat
get-storybook-story-instructionsGuidance on writing effective stories + interaction tests

Agent Testing Loop

# 1. Generate component + CSF3 story
# 2. Run tests via MCP
results = run-story-tests(
    stories=[{ "storyId": "button--primary" }],
    a11y=True
)
# 3. If failures: read violations, fix, retry (max 3)
# 4. Preview in chat for visual confirmation
preview-stories(stories=[{ "storyId": "button--primary" }])

Setup

npx storybook add @storybook/addon-mcp   # current: 0.6.0, Apr 2026
# Enable docs toolset in .storybook/main.ts:
#   componentsManifest: true    # was experimentalComponentsManifest (SB 10.3 rename, default-on)
npx mcp-add --type http --url "http://localhost:6006/mcp" --scope project

See storybook-mcp-integration skill for full tool reference and patterns.


References

  • references/storybook-migration-guide.md — Migration path from Storybook 9 to 10
  • references/storybook-ci-strategy.md — CI pipeline configuration for visual, interaction, and a11y testing
  • references/storybook-addon-ecosystem.md — Essential addons for Storybook 10 in 2026

Related Skills

  • storybook-mcp-integration — Storybook MCP tools: component discovery, testing, previews
  • react-server-components-framework — React 19 + Next.js 16 patterns (component architecture)
  • accessibility — Broader accessibility patterns beyond Storybook
  • devops-deployment — CI/CD pipeline patterns for automated testing

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.25%
按下载量换算191

Claude

29.92%
按下载量换算158

Cursor

16.69%
按下载量换算88

Gemini CLI

8.51%
按下载量换算45

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills