agent-skills / accelint-react-testing
AGENTS.md24 starsChanged 3 months agoApache-2.0View on GitHub
Note: This document is mainly for agents and LLMs to follow when writing or reviewing React component tests with Testing Library. Humans may also find it useful, but guidance here is optimized for automation and consistency by AI-assisted workflows. Comprehensive guide for React Testing Library best practices, designed for AI agents and LLMs. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/accelint-design-foundation/AGENTS.mdAGENTS.md
- skills/accelint-eval-architect/AGENTS.mdAGENTS.md
- skills/accelint-nextjs-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-prompt-manager/AGENTS.mdAGENTS.md
- skills/accelint-react-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-readme-writer/AGENTS.mdAGENTS.md
- skills/accelint-security-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/references/agents.mdAGENTS.md
- skills/accelint-ts-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-ts-documentation/AGENTS.mdAGENTS.md
- skills/accelint-ts-performance/AGENTS.mdAGENTS.md
- skills/accelint-ts-testing/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- accelint-ac-to-playwrightSkill
- accelint-architecture-docSkill
- accelint-archive-synthesisSkill
- accelint-design-foundationSkill
- accelint-english-managerSkill
- accelint-eval-architectSkill
- accelint-nextjs-best-practicesSkill
- accelint-onboard-agentsSkill
- accelint-onboard-openspecSkill
- accelint-persona-reviewSkill
- accelint-prompt-managerSkill
- accelint-qrspi-applySkill
- accelint-qrspi-archiveSkill
- accelint-qrspi-proposeSkill
- accelint-react-best-practicesSkill
- accelint-react-testingSkill
- accelint-readme-writerSkill
- accelint-security-best-practicesSkill
- referencesSkill
- accelint-skill-managerSkill
- accelint-skill-proseSkill
- accelint-tanstack-query-best-practicesSkill
- accelint-ts-audit-allSkill
- accelint-ts-best-practicesSkill
- accelint-ts-documentationSkill
- accelint-ts-performanceSkill
- accelint-ts-testingSkill
- constraints-extractorSkill
- context-driftSkill
- epistemic-mapperSkill
- generate-docsSkill
- jargon-extractorSkill
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
Use accessible query hierarchy: getByRole > getByLabelText > getByText > getByTestId.
- Distinctive: line 49
Use @testing-library/user-event for realistic interaction sequences, not fireEvent.
- Distinctive: line 57
Create test utils that wrap components with Context, Redux, Router providers.
- Distinctive: line 65
Never test implementation details, use container queries, rely on excessive snapshots, use queryBy for presence, or put side effects in …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Testing Library
Note: This document is mainly for agents and LLMs to follow when writing or reviewing React component tests with Testing Library. Humans may also find it useful, but guidance here is optimized for automation and consistency by AI-assisted workflows.
Abstract
Comprehensive guide for React Testing Library best practices, designed for AI agents and LLMs. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a specific rule.
Token efficiency principle: This guide maximizes knowledge delta by providing only expert-level insights and non-obvious patterns. All rules assume understanding React Testing Library basics, React fundamentals, and standard testing patterns. Focus is on non-obvious decisions, accessibility-first testing, and avoiding common pitfalls.
How to Use This Guide
- Start here: Scan the rule summaries to identify relevant optimizations
- Load references as needed: Click through to detailed examples only when implementing
- Progressive loading: Each reference file is self-contained with ❌/✅ examples
This structure minimizes context usage while providing complete implementation guidance when needed.
Quick Reference
- 1.1 Query Priority - Use accessible queries before test IDs (role > label > text > testId)
- 1.2 Query Variants - getBy for sync, findBy for async, queryBy for absence
- 1.3 User Events - Use userEvent over fireEvent for realistic interactions
- 1.4 Async Testing - Handle promises with findBy, waitFor, act patterns
- 1.5 Custom Render - Wrap components with providers in test utils
- 1.6 Accessibility Queries - Query by role, ARIA attributes, semantic HTML
- 1.7 Anti-patterns - Avoid implementation details, container queries, wrapper usage
1. Testing Patterns
1.1 Query Priority
Use accessible query hierarchy: getByRole > getByLabelText > getByText > getByTestId. View detailed examples
1.2 Query Variants
getBy* for immediate presence, findBy* for async appearance, queryBy* to assert absence. View detailed examples
1.3 User Events
Use @testing-library/user-event for realistic interaction sequences, not fireEvent. View detailed examples
1.4 Async Testing
Handle async with findBy queries and waitFor; avoid act warnings with proper awaiting. View detailed examples
1.5 Custom Render
Create test utils that wrap components with Context, Redux, Router providers. View detailed examples
1.6 Accessibility Queries
Query by semantic roles and labels; test ensures accessibility by design. View detailed examples
1.7 Anti-patterns
Never test implementation details, use container queries, rely on excessive snapshots, use queryBy for presence, or put side effects in waitFor. View detailed examples
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

