React Component Testing

RTL + MSW + vitest-axe component-test layer for a Vite + React + TypeScript SPA under Vitest. Use when writing or setting up component tests that render a real component tree, drive it as a user does (React Testing Library + user-event), mock the NETWORK boundary (Mock Service Worker v2 — not the module), and assert the rendered output is accessible (vitest-axe toHaveNoViolations). Covers the jsdom test environment (explicitly not happy-dom, which breaks axe), accessible-query priority, the always-await user-event v14 rule, async findBy/waitFor, the MSW setupServer lifecycle, intercepting a generated @hey-api/openapi-ts client at the fetch layer, a per-test TanStack Query QueryClientProvider with retry:false, and form + request-body + a11y assertions. The middle of the test pyramid: above Vitest unit tests, below Playwright e2e.

bm629 d2d3446 6 files · 48.6 KB Updated

File contents

bm629/agent-skills/tree/main/skills/react-component-testing commit d2d34461ca

Frequently asked questions

npx skillmds@latest add bm629/react-component-testing