playwright-component-testing
БесплатноЗапускает вложенные скриптыНе проверенSet up component testing with Playwright using a story gallery — scaffold stories and a gallery dev page driven by the built-in mount fixture, no dedicated…
от PracticalSwan★ 25 звёзд на GitHubОб этом скилле
Component Testing with Playwright
Test components with regular Playwright e2e tests against a small story gallery page hosted by the app's own dev server. The workflow does not require the retired experimental component-testing runtime, but the built-in mount fixture comes from the project's @playwright/test package and the gallery still needs its framework and bundler dependencies.
Concept
- A story is a tiny wrapper component that embeds the component under test in one specific scenario: hard-coded props, mock data, providers, recorded callbacks. Stories live next to the component in
*.story.tsx(or.ts/.jsx/.js/.vue) files; each named export is one story. - The gallery is a single page you implement to
references/gallery-spec.md: it exposeswindow.mount(params)/window.unmount()that render a story — resolved from your story files (e.g. withimport.meta.glob) — into#root. It is framework-specific and yours to own — there is no template to copy for it. - Tests are plain Playwright tests. The built-in
mount(storyId, props?)fixture (from@playwright/test) drives the gallery'swindow.mountand returns aLocatorfor the gallery root (#root). Scope the queries from there —component.getByRole('button').click(), notcomponent.click(). Nothing to scaffold for it.
Everything the component needs must be set up inside the story (it runs in the browser); everything the test asserts must be observable through the page (DOM, URL, network). Where the component takes callbacks, the story creates the state, provides the callbacks and records the state into a hidden form for the test to assert on. mount(id, props) passes plain serializable props to the story.
Prerequisites
Confirm the project owns the test-runner dependency before changing its package manifest:
npm ls --depth=0 @playwright/test playwright
If @playwright/test is absent, ask for approval before running
npm install --save-dev @playwright/test. Install a browser only when the
project's test setup needs it and the user approves the download:
npx --no-install playwright install chromium
Do not silently turn this skill into a global test-runner or browser install.
Setup workflow
Detect the framework and bundler. React vs Vue decides the framework notes and example story to follow. Then:
- App runs on Vite (has
vite.config.*): the gallery is served by the existing dev server at/playwright/gallery/index.html— Vite serves any.htmlfile under the project root, the app's plugins/aliases/CSS apply automatically, andvite buildignores it. No extra server needed. - Anything else (Next.js, webpack, no dev server): run a small standalone dev server (e.g. Vite) that serves the gallery page, and point
baseURLat it. Requiresviteand the framework plugin as devDependencies.
- App runs on Vite (has
Implement the gallery to
references/gallery-spec.md: a page at<project>/playwright/gallery/that renders the requested story into#root. Start from the worked example in the spec and the framework notes inreferences/react.md/references/vue.md. Keep story discovery (import.meta.glob) and the framework mount here — this is the only framework-specific glue, so keep it small. Import the app's global CSS the same way the app's own entry does.Configure Playwright — add to
playwright.config.ts:projects: [ { name: 'components', testDir: './tests/components', use: { ...devices['Desktop Chrome'], baseURL: 'http://localhost:5173/playwright/gallery/index.html', serviceWorkers: 'block', reuseContext: true }, }, ], webServer: { command: 'npm run dev', // or: npx vite --config playwright/vite.config.ts url: 'http://localhost:5173/playwright/gallery/index.html', // standalone server: http://localhost:3100/playwright/gallery/index.html reuseExistingServer: !process.env.CI, },Match the port to the dev server.
mountnavigates tobaseURL, so setbaseURLto the gallery's URL.serviceWorkers: 'block'keeps the app's own service worker from serving cached responses that would shadow yourpage.route()mocks.reuseContext: truereuses the browser context across tests in a worker (as the old component-testing runtime did) — a large speedup for component suites. If the config already has projects/webServer, merge instead of replacing.Write a first story next to an existing component, modeled on
templates/<react|vue>/Button.story.*.Write a first spec, modeled on
templates/react/button.spec.ts, importingtest/expectfrom@playwright/test.Run:
npx --no-install playwright test --project=components. Openhttp://localhost:5173/playwright/gallery/index.htmlin a browser to eyeball all stories.
Conventions
- Story id: path under
src/without the.story.*extension, plus the expor
Установить playwright-component-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл playwright-component-testing?
Set up component testing with Playwright using a story gallery — scaffold stories and a gallery dev page driven by the built-in mount fixture, no dedicated component-testing runtime. Use when asked to test React or Vue components in isolation with Playwright, or to migrate off @playwright/experimental-ct-react / -vue.
Как установить скилл playwright-component-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл playwright-component-testing запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic