testing-guidelines

Define Vitest and Testing Library conventions for deterministic React tests.

46|28|Updated Sep 8, 2025
One-click install
npx skills add https://github.com/divinevideo/divine-web --skill testing-guidelines-divinevideo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-guidelines
Source: https://github.com/divinevideo/divine-web/tree/main/.agents/skills/testing-guidelines
Command: npx skills add https://github.com/divinevideo/divine-web --skill testing-guidelines-divinevideo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams avoid flaky, overly brittle tests by standardizing how tests are written, mocked, and executed for divine-web.

Core Features & Use Cases

  • Vitest + jsdom conventions for reliable unit/component test structure in React projects.
  • User-facing query assertions using Testing Library queries like getByRole and getByText to validate real behavior instead of implementation details.
  • Deterministic testing rules covering fake timers, scoped mocks, and isolation so tests pass consistently in any order.
  • Use cases: validating UI changes with component tests, verifying utility behavior with colocated unit tests, and running Playwright visual regression checks safely.

Quick Start

Load testing-guidelines when you update a feature, then write a new Vitest test using user-facing queries and deterministic mocks so it runs reliably with npm run test.

Frequently Asked Questions about testing-guidelines

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

FAQPage Schema
How do I write deterministic Vitest tests that don't flake in React projects?

To write deterministic Vitest tests, use scoped mocks, isolate test execution, and apply fake timers to control time-dependent behavior. This ensures your tests pass consistently regardless of execution order and eliminates flaky test runs.

Why should I use Testing Library queries instead of testing implementation details?

Using Testing Library queries like getByRole and getByText validates real user-facing behavior instead of brittle implementation details. This approach focuses assertions on accessible elements and visible text, making your component tests resilient to internal refactoring.

What's the best way to structure unit and component tests for a React web application?

The best way to structure React tests is by colocating *.test.ts(x) files directly alongside your source code. This convention covers unit tests for utility functions and component tests for UI elements, keeping relevant tests easy to locate and maintain.

Can I use Playwright for visual regression testing alongside Vitest and jsdom?

Yes, you can use Playwright for visual regression verification alongside Vitest and jsdom. Vitest handles unit and component testing logic, while Playwright executes browser-based visual regression checks during development to validate UI appearance.

When should I skip or fail tests during development without breaking my test suite?

You should skip or fail tests during development by following clear execution rules defined by your testing conventions. Applying these structured rules for skipping or failing ensures that incomplete features do not disrupt the deterministic execution of the overall test suite.