From web
Writes component tests using Vitest Browser Mode with Playwright for real-browser testing. Use when testing React components, writing browser-based tests, verifying UI behavior, testing forms, or deciding whether a component needs a test.
How this skill is triggered — by the user, by Claude, or both
Slash command
/web:component-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Vitest Browser Mode with Playwright. Tests run in real Chromium — every DOM API, CSS layout, and browser behavior is authentic.
Vitest Browser Mode with Playwright. Tests run in real Chromium — every DOM API, CSS layout, and browser behavior is authentic.
foo.browser.test.tsx next to foo.tsxdescribe named after the componenttest, not itrender() is async — always await itdescribe("SearchFilter", () => {
test("filters results on input change", async () => { ... });
test("shows empty state when no matches", async () => { ... });
});
Test when a component has:
useState or state management logicuseEffect or side effectsSkip when a component:
import { render } from "vitest-browser-react";
import { page } from "vitest/browser";
import { describe, expect, test, vi } from "vitest";
| API | Use |
|---|---|
await render(<C />) | Mount component |
page.getByRole("button", { name }) | Query by ARIA role |
page.getByText("text") | Query by text content |
page.getByLabelText("label") | Query by label |
locator.click() | Click interaction |
locator.fill("value") | Type into input |
await expect.element(locator) | Auto-retry assertion (1s) |
expect(value) | Synchronous assertion |
expect.element() vs expect()| Use | When |
|---|---|
await expect.element(locator) | Page locator queries — auto-retries until pass |
expect(value) | Mock assertions, container.querySelector(), non-DOM values |
See examples/ for complete test examples by pattern:
| Example | When to use |
|---|---|
examples/render-and-query.md | Basic rendering, role and text queries |
examples/user-interactions.md | Clicks, toggles, stateful interactions |
examples/form-testing.md | Form inputs, submission, validation |
examples/conditional-rendering.md | Show/hide content based on props or state |
examples/container-queries.md | DOM structure, data-* attributes, container.querySelector() |
examples/compound-components.md | Multi-part composed components |
.browser.test.tsx extensiondescribe named after the componenttest, not itrender() is awaitedexpect.element() for locator assertionsnpx claudepluginhub kvnwolf/devtools --plugin webGuides authoring and reviewing frontend unit, component, and lightweight integration tests using React Testing Library, Vue Test Utils, accessible queries, user-event interactions, and controlled mocks.
Tests React components with React Testing Library, Vitest/Jest, MSW for network mocking, and axe accessibility assertions. Guides test vs E2E decisions.
Generates component tests (React Testing Library, Vue Test Utils, snapshot) for existing components. Use when adding test coverage after component creation.