testing

Enforce Vitest and Testing Library patterns for frontend tests.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/theofernandezz/ai-library --skill testing-theofernandezz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/theofernandezz/ai-library/tree/main/.opencode/skills/testing
Command: npx skills add https://github.com/theofernandezz/ai-library --skill testing-theofernandezz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Establishes clear, reusable frontend testing conventions using Vitest and Testing Library to reduce flaky tests and speed up development.

Core Features & Use Cases

  • Architecture guidance covering unit, integration, and UI tests; recommended use of MSW for API mocking and userEvent for realistic interactions.
  • Enforced patterns: Arrange-Act-Assert (AAA), role-based queries, avoid testing implementation details, and resilient error/loading handling checks.
  • Co-located test structure, coalesced checklist, and configuration guidance to maintain consistency across React SaaS frontends.

Quick Start

Install Vitest and Testing Library and begin applying the recommended testing patterns to your React tests.

Frequently Asked Questions about testing

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

FAQPage Schema
What are the best practices for structuring React tests with Vitest and Testing Library?

Vitest and Testing Library best practices include co-locating tests, following Arrange-Act-Assert patterns, using role-based queries, and avoiding testing implementation details. This ensures reliability and consistency across SaaS frontends while reducing flaky tests.

How do I mock API requests in React tests using MSW?

Mock API requests in React tests using MSW to simulate realistic network behavior. MSW works with Vitest and Testing Library to intercept requests, providing consistent test data and isolating frontend components from backend dependencies.

Why should I use userEvent over fireEvent in Testing Library?

Use userEvent over fireEvent in Testing Library because userEvent simulates realistic user behavior more accurately. Combined with Vitest, it creates reliable integration and UI tests that better reflect actual user interactions.

Can I use Vitest and Testing Library for integration tests in SaaS frontends?

Yes, Vitest and Testing Library support integration tests in SaaS frontends. Architecture guidance covers unit, integration, and UI tests, with patterns for resilient error and loading state handling using MSW for API mocking.

What testing patterns should I avoid when using Vitest with React?

Avoid testing implementation details, using non-role-based queries, and skipping error/loading state checks when using Vitest with React. Forbidden patterns are codified to enforce robust frontend testing practices and maintain consistency across your test suite.