dariopalminio/agile-sddf-extension/test-react-testing-library
Claude Code and agent skill by dariopalminio/agile-sddf-extension
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Tests React components with Vitest + Testing Library + happy-dom + axe-core (rendering, interaction, accessibility). Use when testing UI components, forms, or hooks that render in the DOM. Invoke for "Testing Library", "componente React", "render", "screen", "userEvent", "axe". DO NOT USE FOR unit tests, E2E tests, or backend tests.
Install
npx vskill@latest install dariopalminio/agile-sddf-extension/test-react-testing-librarySemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as dariopalminio/agile-sddf-extension/test-react-testing-library.
React Testing Library Skill
Overview
Test React components with Vitest + Testing Library + happy-dom + axe-core, focusing on rendering, user interaction, and accessibility from the user's perspective.
Capabilities:
- Implement the RED phase tests of TDD.
- Render and query UI components, forms, and hooks in the DOM.
- Simulate real user interactions with
@testing-library/user-event. - Assert behavior with
findBy/waitForasync patterns and jest-dom matchers. - Check accessibility via role/label queries and axe-core.
Limitations:
- Not for backend tests or true browser E2E tests.
- Avoid testing implementation details (internal state, methods, lifecycle, child internals).
Prerequisites
- A React project with Vitest,
@testing-library/react,@testing-library/user-event, happy-dom and axe-core installed. @testing-library/jest-dommatchers configured in the test setup.- Test files co-located with the components they test (
*.test.tsx).
Examples
The patterns, query references, and snippets below show how to write tests with React Testing Library.
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)
Agreements tests location
- Unit / Component: Co-locate with same folder as the code (the code as *.test.ts). Colocate test files next to the component they test.
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 (automatic in Vitest with globals: true) | |
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 |
References
For more details, consult these reference files (loaded on demand):
| Topic | Link | |
|---|---|---|
| Installation | references/testing-library-installation.md | |
| Queries | references/testing-library-queries.md | |
| User Events | references/testing-library-user-events.md | |
| API | references/testing-library-api.md | |
| Async | references/testing-library-async.md | |
| Debugging | references/testing-library-debugging.md | |
| Config | references/testing-library-config.md | |
| Happy DOM | references/happy-dom-tests.md | |
| Vitest | references/vitest-component.md | |
| axe-core | references/axe-core.md | |
| Type Testing | references/type-level-testing.md |
These files are only loaded if the agent needs additional context.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/test-react-testing-library/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
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/dariopalminio/agile-sddf-extension/test-react-testing-library)