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.ts for src/components/Button.vue.// Each named export is one story: a scenario-specific wrapper around the// component. Wire providers, mock data, state and callbacks here, not in tests.// Alternatively, write a story as a Button.<scenario>.story.vue single-file// component — its default export is the story.import { defineComponent, h, ref } from 'vue';import Button from './Button.vue'; export const Primary = defineComponent(() => () => h(Button, { title: 'Submit' })); export const Disabled = defineComponent(() => () => h(Button, { title: 'Submit', disabled: true })); // 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 = defineComponent(() => {  const clicks = ref(0);  return () => h('div', [    h(Button, { title: 'Submit', onClick: () => clicks.value++ }),    h('form', { hidden: true }, [      h('input', { 'data-testid': 'click-count', readonly: true, value: String(clicks.value) }),    ]),  ]);});