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.

Install
npx skills add 'https://github.com/microsoft/playwright/tree/main/packages/playwright-core/src/tools/skills/playwright-component-testing'
Download bundle ↓
main · 500c9c8Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md
// Example story file. Stories live next to the component they exercise:// this file is src/components/Button.story.tsx for src/components/Button.tsx.// Each named export is one story: a scenario-specific wrapper around the// component. Wire providers, mock data, state and callbacks here, not in tests.import { useState } from 'react';import { Button } from './Button'; export const Primary = () => <Button title="Submit" />; export const Disabled = () => <Button title="Submit" disabled />; // The story owns the state and provides the callbacks. Record the state into// a hidden form for the test to assert on.export const CountsClicks = () => {  const [clicks, setClicks] = useState(0);  return <>    <Button title="Submit" onClick={() => setClicks(count => count + 1)} />    <form hidden><input data-testid="click-count" readOnly value={String(clicks)} /></form>  </>;};