React testing

From HoangNguyen0403/agent-skills-standard · View interactive version

React testing is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. Test React components with RTL and Jest/Vitest. Use when writing React component tests with React Testing Library, Jest, or Vitest.

How to use this skill

Skill file

React Testing

**Priority: P1 (HIGH)**

Universal anti-slop rules (naming, identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps,

shallow assertions, coverage): anti-slop-rules.md. Only web deltas

follow.

Core Philosophy

holds.

Core Rule Anchors

Arrange-Act-Assert.

query by accessible role (getByRole, findByLabelText). Avoid fireEvent; ban CSS or DOM-hierarchy selectors.

outcomes and DOM changes.

or Redux dispatchers; tests must exercise real component data flow.

.loc.source.body substrings (GUARD-TS-STATIC-PINNING); test the hook or query component. Never loop

Object.keys(locales/*.json) or assert typeof en[k] === 'string'; assert rendered text via findByText/getByRole.

Never keep <stem>.test.tsx beside a legacy <stem>.test.jsx (GUARD-TS-DUAL-EXT); migrate it. Ban pass-through mock

echoes (expect(wrapper()).toBe(X) without domain transformations).

Implementation Guidelines

GUARD-TS-CONDITIONAL-ASSERT, GUARD-TS-SELF-MOCK). Ban setTimeout sleeps > 0ms (GUARD-REACT-02); use

await screen.findBy* or waitFor.

Anti-Patterns & Banned Smells

References

See references/REFERENCE.md for MSW API mocking, Context testing, form testing, and React Router

patterns.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.