playwright-component-testing

Test React and Vue components in isolation using Playwright with a story gallery page.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/CatalinPoata/SistemPortalDMS --skill playwright-component-testing-catalinpoata
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: playwright-component-testing
Source: https://github.com/CatalinPoata/SistemPortalDMS/tree/main/API-DMS-TESTS/bin/Debug/net9.0/.playwright/package/lib/tools/skills/playwright-component-testing
Command: npx skills add https://github.com/CatalinPoata/SistemPortalDMS --skill playwright-component-testing-catalinpoata

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @playwright/test, and includes references (resource) components.

What problem does it solve? Testing UI components in isolation normally requires a dedicated component-testing runtime like @playwright/experimental-ct-react or -vue, which adds bundler integration, extra packages, and maintenance overhead. This Skill replaces that with plain Playwright e2e tests driven against a small story gallery page hosted by the app's own dev server. ## Core Features & Use Cases - Story-based component scenarios: Define each component state as a named export in *.story.tsx / .story.vue files next to the component, with callbacks and state recorded into hidden form inputs for assertions. - Built-in mount fixture: Use Playwright's mount(storyId, props) fixture to render stories into the gallery's #root and receive a scoped Locator, with update() for state-preserving prop transitions and unmount() for teardown checks. - Migration path from experimental CT: Map mount(<Button/>) JSX calls, beforeMount hooks, and hooksConfig from @playwright/experimental-ct-react/-vue onto stories, props, and the gallery's window.mount. - Use Case: A team wants screenshot and interaction tests for a design-system Button component without adopting the experimental CT packages; they scaffold a gallery page, write Button.story.tsx exports, and run npx playwright test --project=components. ## Quick Start Set up component testing for my React app with Playwright by creating the gallery page and a first story for my Button component.

Frequently Asked Questions about playwright-component-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test React components with Playwright without experimental-ct?▼

Create a story gallery page served by your dev server that exposes window.mount and window.unmount, then write plain Playwright tests using the built-in mount fixture. Each component scenario becomes a named export in a .story.tsx file next to the component.

How to migrate from @playwright/experimental-ct-react to plain Playwright?▼

Convert each mount(<Component/>) JSX call into a story export, keep plain data props as mount's second argument, and move beforeMount hooks into the gallery's window.mount. Spy assertions become toHaveValue() checks on state the story records into hidden form inputs.

Does Playwright component testing work with Vue single-file components?▼

Yes, Vue 3 is supported through .story.ts render-function stories or .story.vue single-file-component stories. The gallery mounts a reactive host once with createApp and updates refs so prop changes re-render in place and preserve state.

How do I test component callbacks and events in Playwright?▼

The story owns the state and provides the callbacks, recording observed values into hidden form inputs with data-testid attributes. Tests perform actions and assert with toHaveValue(), which retries until the recorded state lands.

Why is my Playwright component test state resetting on update()?▼

State resets when the gallery recreates its root on each window.mount call instead of reusing it. Create the root once and render into it on every call so the framework reconciles and preserves component-internal state across update().

What are the limitations of the story gallery approach?▼

Per-test JSX trees cannot cross into the browser, so each composition needs its own story export, and story ids are strings resolved at runtime, so renames break specs without compile-time errors. Props passed to mount must be plain serializable data.