react-testing

A set of rules for testing React interfaces with Vitest, React Testing Library, and Playwright. It covers isolated component tests and browser-based end-to-end tests.

In plain words
What is it for?
Use it when writing or organizing React tests, including component, hook, utility, mock, fixture, and browser tests. It also sets a target of more than 80% line coverage.
Why use it?
It gives UI tests a consistent structure and checks how users interact with the interface instead of relying on internal code details.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/aps08/fullstack-clean-architecture/react_testing
Any agent
npx skills add aps08/fullstack-clean-architecture --skill react_testing
Clone the repo
git clone --depth 1 https://github.com/aps08/fullstack-clean-architecture

Made for: Claude Code, Codex.

Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 921 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.00921
Opus 5 $0.00012 $0.00461
Sonnet 5 $0.00005 $0.00184
Haiku 4.5 $0.00002 $0.00092

Measured yesterday against content hash 8745d07e10c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

react-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/react_testing/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

React Testing Skill

Testing Tools

  • Use Vitest as the primary test runner.
  • Use @testing-library/react for component behavior testing.
  • Use Playwright for all End-to-End (E2E) testing.

Directory Structure

All test files are located under web/tests/ and are organized as follows:

  • tests/unit/: Contains unit tests testing components, hooks, features, and utils in isolation using Vitest and React Testing Library.
  • tests/e2e/: Contains end-to-end integration tests that run in a browser using Playwright.
  • tests/mocks/: Contains mocks for external integrations or APIs.
  • tests/fixtures/: Contains reusable test fixtures or data.
  • tests/test_utils.tsx: Contains common testing utilities, such as a custom render wrapper.

Standards & Best Practices

  • Test user interactions rather than implementation details.
  • Ensure all tests are isolated and don't depend on global state.
  • No Comments Needed: No need to add comments inside any of the test code (like // Arrange, // Act, // Assert). The test or it description strings are enough to explain the test logic.
  • Code Coverage: Ensure test coverage is strictly more than 80% of the lines.
  • Mocking: Use vi.fn() for mock functions and vi.mock() for module mocks in Vitest.

Example: Unit Test (Vitest + Testing Library)

import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { ArchiveCard } from "@/components/ArchiveCard";

const todo = {
  id: "todo-1",
  title: "Old Project Notes",
  isCompleted: false,
  createdAt: "2024-01-01T00:00:00Z",
  updatedAt: "2024-03-01T00:00:00Z",
};

describe("ArchiveCard", () => {
  it("renders the todo title", () => {
    render(<ArchiveCard todo={todo} onRestore={vi.fn()} onDelete={vi.fn()} />);
    expect(screen.getByText("Old Project Notes")).toBeInTheDocument();
  });

  it("calls onRestore with the todo id when Restore is clicked", () => {
    const onRestore = vi.fn();
    render(
      <ArchiveCard todo={todo} onRestore={onRestore} onDelete={vi.fn()} />,
    );
    fireEvent.click(screen.getByRole("button"));
    fireEvent.click(screen.getByText("Restore"));
    expect(onRestore).toHaveBeenCalledWith("todo-1");
  });
});

Read the full file on GitHub · 100 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 100 lines · 24 tokens per session scan A 8745d07e10c7

Subscribe to this mod's changes

react-testing is a skill published in the GitHub repository aps08/fullstack-clean-architecture (2 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 24 tokens to every session and 921 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.