testing-patterns

Write unit, integration, E2E, and visual regression tests using Vitest, Testing Library, and Playwright.

Updated May 16, 2026
One-click install
npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill testing-patterns-organvm-i-theoria
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/organvm-i-theoria/_agent-ontology/tree/main/.agents/skills/testing-patterns
Command: npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill testing-patterns-organvm-i-theoria

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing tests that actually catch bugs without slowing development is hard—teams struggle with what to test, how to mock dependencies, and how to structure unit, integration, and E2E suites across the stack. ## Core Features & Use Cases - Full-stack test patterns: AAA-structured unit tests, React Testing Library component tests, API and database integration tests, and Playwright E2E flows with page objects. - Mocking strategies: Recipes for fetch, MSW handlers, Prisma, hooks, timers, file system, and external services, with guidance on when to mock versus integrate. - Coverage and CI guidance: Realistic coverage targets (70-80% lines/branches) and a GitHub Actions workflow for running tests with coverage reporting. - Use Case: You are adding tests to a React app with a REST API. Use this Skill to scaffold Vitest component tests with MSW-mocked endpoints, then add a Playwright login flow with saved authentication state. ## Quick Start Write unit tests for my formatCurrency utility and a Playwright E2E test for the login flow using the testing patterns in this skill.

Frequently Asked Questions about testing-patterns

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

FAQPage Schema
How do I write unit tests with Vitest?▼

Structure Vitest unit tests with the AAA pattern: arrange inputs, act by calling the function, then assert the result. Use describe/it blocks, vi.fn() for mocks, and it.each for parameterized cases across multiple inputs.

How to mock API calls in React tests?▼

Mock API calls with MSW by defining request handlers that return JSON responses, then starting the server in your test setup file. For simpler cases, stub global.fetch with vi.fn() and mockResolvedValueOnce per test.

Vitest vs Jest for a new project?▼

Vitest is the default choice in this skill for Vite-based projects because it shares configuration with the build pipeline and runs faster. Jest patterns like module mocking and spies translate directly via the vi namespace.

Does Playwright support authentication reuse across tests?▼

Yes, Playwright supports saving browser state with storageState after a one-time login setup project. Subsequent test projects load the saved state file, skipping repeated logins and speeding up E2E suites.

What code coverage percentage should I target?▼

Target 70-80% for lines and branches, and 80%+ for functions, with 90%+ on critical code paths. Chasing 100% coverage does not guarantee good tests, bug-free code, or covered edge cases.

When should I mock versus use a real database in tests?▼

Mock the database in unit tests to keep them fast and isolated, but use a real test database in integration tests to verify actual queries and constraints. The rule of thumb is to mock only at system boundaries.