react-testing
Installation
SKILL.md
React Testing
Quick reference for testing React components. Builds on the typescript-testing skill (Vitest config, mocking, coverage) — this skill covers React-specific patterns. Reference files provide full examples and edge cases.
Component Testing
Query Priority
Always prefer queries that reflect how users see the page:
| Priority | Query | Example |
|---|---|---|
| 1 (best) | getByRole |
screen.getByRole("button", { name: /guardar/i }) |
| 2 | getByLabelText |
screen.getByLabelText(/correo/i) |
| 3 | getByText |
screen.getByText(/bienvenido/i) |
| 4 | getByAltText |
screen.getByAltText("Doctor photo") |
| Last resort | getByTestId |
screen.getByTestId("complex-widget") |
User Events
Related skills