writing-tests

Enforce consistent testing conventions across client, server, and E2E suites.

37|6|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/carrotwaxr/peek-stash-browser --skill writing-tests-carrotwaxr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-tests
Source: https://github.com/carrotwaxr/peek-stash-browser/tree/main/.claude/skills/writing-tests
Command: npx skills add https://github.com/carrotwaxr/peek-stash-browser --skill writing-tests-carrotwaxr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a single, consistent testing convention for Peek to eliminate flaky tests, unclear mocking patterns, and inconsistent coverage between client, server, and E2E suites so teams can write reliable, maintainable tests.

Core Features & Use Cases

  • Client unit testing: Conventions for Vitest 3.x with React Testing Library, user-event, happy-dom, test file locations, query priorities, and rendering helpers.
  • Server unit & integration testing: Patterns for mocking Prisma, enforcing sequential execution for DB-sensitive tests, and running integration tests against a dedicated Stash test instance using STASH_TEST_URL and STASH_TEST_API_KEY.
  • E2E with Playwright: Centralized Playwright conventions, storage-state auth setup, CI and local run instructions, and locator/assertion priorities to avoid brittle tests.
  • CI & quality gates: Coverage thresholds and command patterns to run client, server, integration, and E2E suites reliably.

Quick Start

Run the client tests by executing the project's Vitest command in the client directory and follow the documented naming, mocking, and query-priority conventions.

Frequently Asked Questions about writing-tests

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

FAQPage Schema
How do I structure consistent Vitest tests across client and server codebases?

Consistent Vitest tests require applying unified conventions for client component tests with React Testing Library, server integration tests against a test instance, and Playwright E2E flows to ensure reliable coverage.

How do I run server integration tests against a Stash test instance?

Server integration tests require configuring STASH_TEST_URL and STASH_TEST_API_KEY environment variables to connect to a dedicated Stash test instance, while enforcing sequential execution for database-sensitive server unit tests.

What's the best way to mock Prisma in server unit tests?

Mocking Prisma in server unit tests follows established patterns within Vitest to isolate database dependencies, ensuring tests run sequentially to prevent data conflicts and maintain reliable execution.

Do I need happy-dom for client component testing with React Testing Library?

Client component testing with React Testing Library requires happy-dom as the configured test environment alongside Vitest 3.x, using specific query priorities and rendering helpers for consistent UI assertions.

How do I configure Playwright E2E tests to avoid brittle UI flows?

Playwright E2E tests avoid brittle flows by following centralized conventions for storage-state auth setup, applying locator and assertion priorities, and using consistent CI and local run instructions.

What coverage thresholds should I set for CI quality gates in testing?

CI quality gates enforce coverage thresholds using specific command patterns to reliably run client, server, integration, and E2E test suites, ensuring maintainable and consistent test coverage.