test-component

test-component is a skill for Claude Code from MuhammadUsmanGM/claude-code-best-practices. It costs 50 tokens per session (501 once invoked), scanned A, original, MIT.

A workflow for writing tests for an existing React component with React Testing Library, a tool for checking user-visible behaviour in React interfaces. It follows the project's existing test style and prefers queries based on accessible roles and labels.

In plain words
What is it for?
Use it to add tests beside a React component, covering its initial display, user interactions, states, and callbacks. Network requests are tested through the project's shared request boundary rather than by mocking component internals.
Why use it?
It keeps tests focused on what users can see and do instead of the component's internal implementation. It also encourages testing loading, empty, error, interaction, and callback behaviour where those cases exist.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to add tests beside a React component, covering its initial display, user interactions, states, and callbacks. Network requests are tested through the project's shared request boundary rather than by mocking component internals.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/muhammadusmangm/claude-code-best-practices/test-component
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.

Any agent
npx skills add MuhammadUsmanGM/claude-code-best-practices --skill test-component
Clone the repo
git clone --depth 1 https://github.com/MuhammadUsmanGM/claude-code-best-practices

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-component

README.md
[![agentmods](https://agentmods.dev/badge/skills/muhammadusmangm/claude-code-best-practices/test-component/github.svg)](https://agentmods.dev/skills/muhammadusmangm/claude-code-best-practices/test-component)
Your own site
<a href="https://agentmods.dev/skills/muhammadusmangm/claude-code-best-practices/test-component"><img src="https://agentmods.dev/badge/skills/muhammadusmangm/claude-code-best-practices/test-component/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-component

Your own site · 80×15
<a href="https://agentmods.dev/skills/muhammadusmangm/claude-code-best-practices/test-component"><img src="https://agentmods.dev/badge/skills/muhammadusmangm/claude-code-best-practices/test-component.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 501 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00050 $0.00501
Opus 5.5 $0.00020 $0.00200
Sonnet 5.5 $0.00010 $0.00100
Haiku 4.5 $0.00005 $0.00050

Measured 1mo ago against content hash 092129a518ce, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

test-component 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 1mo ago.

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.

starters/react/.claude/skills/test-component/SKILL.md · 50 lines

What it actually says

Test Component

Write tests for an existing component following the project's conventions.

Steps

  1. Read the component file. Note its props, any hooks it calls, and whether it fetches data.
  2. Read one existing test file in the same area and mirror its style — imports, render helpers, matcher choices, mock setup.
  3. Plan 3–5 assertions, in this priority order:
    • Renders the expected role/label on mount.
    • Responds to user interaction (click, type) with a visible result.
    • Handles loading / empty / error states if the component has them.
    • Calls the right callback with the right args (if props include callbacks).
  4. Mock at the network boundary. If the component fetches via a shared client in src/api/, add an MSW handler in src/test/msw/ — don't mock the component's internal hooks.
  5. Write the test file next to the component. Name: <Name>.test.tsx.
  6. Run npm test -- <Name> once and report pass/fail. Do not fix the component to make the test pass — if a test reveals a bug, stop and tell the user.

Query priority (enforced)

Use in this order, only falling back when the higher option genuinely doesn't apply:

  1. getByRole with an accessible name
  2. getByLabelText
  3. getByPlaceholderText
  4. getByText
  5. getByTestId — last resort

Rules

  • Never call act() manually. If a test "needs" it, you're testing implementation — rewrite the assertion.
  • Never await new Promise(...) to wait for state. Use findBy* or waitFor.
  • No snapshot tests unless the component has a stable, small render surface (icons, formatted strings). Component snapshots rot fast.
  • Don't edit the component under test. This skill writes tests only.
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. 1mo ago First seen · 50 lines · 50 tokens per session scan A 092129a518ce

Subscribe to this mod's changes

test-component is a skill published in the GitHub repository MuhammadUsmanGM/claude-code-best-practices (97 stars, last pushed 1mo ago), licensed MIT. It adds 50 tokens to every session and 501 once invoked, about $0.0002 per session on Opus 5.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-30.

Related

Other skills, from other repositories

web3-testing

Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.

wshobson/agents · 46 tokens

temporal-python-testing

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

wshobson/agents · 45 tokens

data-quality-frameworks

Implement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.

wshobson/agents · 37 tokens

dbt-transformation-patterns

Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.

wshobson/agents · 47 tokens

principle-test-behavior-not-implementation

Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.

michael-denyer/pstack-claude · 50 tokens

verify-work

Verify feature, bug, UI, API, mobile, security, or deployment work against acceptance criteria.

HoangNguyen0403/agent-skills-standard · 23 tokens