itechmeat/llm-code/react-testing-library
Claude Code and agent skill by itechmeat/llm-code
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
React Testing Library: user-centric component testing with queries, user-event simulation, async utilities, and accessibility-first API. Use when writing React component tests, selecting elements by role/label/text, simulating user events, or testing async UI behavior. Keywords: React Testing Library, @testing-library/react, user-event, queries, render.
Install
npx vskill@latest install itechmeat/llm-code/react-testing-librarySemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
React Testing Library Skill
Quick Navigation
| Topic | Link | |
|---|---|---|
| Queries | references/queries.md | |
| User Events | references/user-events.md | |
| API | references/api.md | |
| Async | references/async.md | |
| Debugging | references/debugging.md | |
| Config | references/config.md |
Installation
Install: npm install --save-dev @testing-library/react @testing-library/dom. Recommended extras: @testing-library/user-event and @testing-library/jest-dom. React 19 requires v16.1.0+.
Core Philosophy
"The more your tests resemble the way your software is used, the more confidence they can give you."
Avoid testing:
- Internal state of components
- Internal methods
- Lifecycle methods
- Child component implementation details
Test instead:
- What users see and interact with
- Behavior from user's perspective
- Accessibility (queries by role, label)
Query Priority
Use queries in this order of preference:
1. Accessible to Everyone (Preferred)
2. Semantic Queries
3. Test IDs (Escape Hatch)
Query Types
| Type | No Match | 1 Match | >1 Match | Async | |
|---|---|---|---|---|---|
getBy... | throw | return | throw | No | |
queryBy... | null | return | throw | No | |
findBy... | throw | return | throw | Yes | |
getAllBy... | throw | array | array | No | |
queryAllBy... | [] | array | array | No | |
findAllBy... | throw | array | array | Yes |
When to use:
getBy*— element existsqueryBy*— element may not exist (assertions likeexpect(...).not.toBeInTheDocument())findBy*— element appears asynchronously
Basic Test Pattern
User Events
Always use @testing-library/user-event over fireEvent:
Async Patterns
waitFor — Retry Until Success
findBy — Built-in waitFor
waitForElementToBeRemoved
Common Patterns
Custom Render with Providers
Testing Hooks
Rerender with New Props
Query Within Container
Debugging
jest-dom Matchers
Configuration
❌ Prohibitions (Anti-patterns)
✅ Best Practices
TextMatch Options
Quick Reference
| Import | Usage | |
|---|---|---|
render | Render component to DOM | |
screen | Query the rendered DOM | |
cleanup | Unmount components (auto in Jest) | |
act | Wrap state updates | |
renderHook | Test custom hooks | |
within | Scope queries to element | |
waitFor | Retry until assertion passes | |
configure | Set global options | |
userEvent.setup() | Create user event instance |
Links
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/react-testing-library/SKILL.md
Popularity
- Repository stars
- 11
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 29 Mar 2026, 8 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/itechmeat/llm-code/react-testing-library)