react-component-testing

A testing approach for React applications that separates tests for small logic, individual components, and complete user journeys across pages.

In plain words
What is it for?
Use it to test hooks and pure functions with Vitest, component behaviour with React Testing Library, and multi-page flows with Playwright.
Why use it?
It helps match each kind of code with an appropriate test and checks what users can observe instead of internal implementation 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/soulcodex/agentic/react-component-testing
Any agent
npx skills add soulcodex/agentic --skill react-component-testing
Clone the repo
git clone --depth 1 https://github.com/soulcodex/agentic

Made for: Claude Code, Codex.

Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 654 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.00059 $0.00654
Opus 5 $0.00030 $0.00327
Sonnet 5 $0.00012 $0.00131
Haiku 4.5 $0.00006 $0.00065

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

Security

Grade A, and why

react-component-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.

skills/ui/react-component-testing/SKILL.md · 84 lines

How it starts

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

React Component Testing Skill

Step 1 — Classify What Needs to Be Tested

Assign each file to a test tier before writing tests:

  • Hook / reducer / pure function -> unit test.
  • Component behavior / interaction -> component test.
  • Multi-page user flow -> end-to-end test.

Step 2 — Write Unit Tests

  • Test hooks with renderHook and explicit inputs.
  • Test reducers and utilities as pure functions.
  • Mock network boundaries; do not mount full UI.
import { describe, expect, it } from 'vitest'
import { authReducer } from './auth.reducer'

it('sets user on login success', () => {
  const state = authReducer({ user: null }, { type: 'login/success', payload: { id: '1' } })
  expect(state.user?.id).toBe('1')
})

Step 3 — Write Component Tests

  • Use React Testing Library queries by role/label/text.
  • Use userEvent for interactions, not low-level DOM event simulation unless necessary.
  • Wrap with providers used in production (router, query client, store) via a shared test render utility.
  • Assert user-visible output and callback side effects.
  • In TypeScript projects, keep TS/JS imports ESM-only and use aliases for cross-directory imports.
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { SaveButton } from './SaveButton'

it('calls onSave when clicked', async () => {
  const onSave = vi.fn()
  render(<SaveButton onSave={onSave} />)
  await userEvent.click(screen.getByRole('button', { name: 'Save' }))
  expect(onSave).toHaveBeenCalledTimes(1)
})

Step 4 — Write End-to-End Tests

  • Use Playwright for full browser flows across routes.
  • Cover one happy path and key failure path for each critical user journey.
  • Keep E2E focused on integration risks, not exhaustive branch coverage.

Step 5 — Verify

  • Each custom hook has unit tests for success and edge behavior
  • Interactive components test primary user interactions
  • No tests assert private state or implementation-only details
  • Critical journeys have Playwright coverage (happy path + failure path)
  • pnpm test passes with zero failures

Read the full file on GitHub · 84 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 84 lines · 59 tokens per session scan A c88edd5c454a

Subscribe to this mod's changes

react-component-testing is a skill published in the GitHub repository soulcodex/agentic (10 stars, last pushed yesterday), licensed MIT. It adds 59 tokens to every session and 654 once invoked, about $0.0003 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.