What problem does it solve?
This Skill streamlines the process of writing effective unit and integration tests for React components, hooks, and utilities using the Vitest testing framework and React Testing Library.
Core Features & Use Cases
- Standardized Testing Patterns: Enforces the Given/When/Then (AAA) structure for clear and maintainable tests.
- Optimized Querying: Guides users to prioritize accessible DOM queries (getByRole, getByLabelText) over brittle selectors.
- Interaction Handling: Promotes the use of
userEvent for realistic user interaction simulation.
- Async Testing: Provides patterns for handling asynchronous operations and assertions effectively.
- Mocking Strategies: Demonstrates best practices for mocking with
vi.fn() and vi.spyOn.
- Use Case: When developing a new form component in React, use this skill to ensure all user interactions like typing and button clicks are correctly tested, and that form submission logic behaves as expected.
Quick Start
Use the vitest skill to write a unit test for the UserProfile component, ensuring it displays the user's name correctly after it's loaded.