Agent skill · software engineering · aiskillstore

react-testing

Testing patterns for React with Jest and React Testing Library. Use when writing tests, mocking modules, testing Zustand stores, or debugging test failures in React web applications.

Why this skill is useful

Provides specific testing patterns and code snippets for React applications using Jest and React Testing Library that the AI wouldn't reliably generate on its own.

What it needs

Requires @tanstack/react-query, @testing-library/react, @testing-library/user-event, jest installed locally. About 5k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

React Testing (Web) Problem Statement React testing requires understanding component rendering, user interactions, and async state management. This skill covers Jest with React Testing Library patterns for web applications. --- Pattern: Zustand Store Testing Problem: Store state persists between tests, causing flaky tests. Key points: Use setState(initialState, true) to replace (not merge) state Get fresh state with getState() after async operations Don't rely on component re-renders in store tests --- Pattern: Async Store Operations Problem: Testing async Zustand actions with proper waiting. --- Pattern: Component Testing --- Pattern: React Query Testing Problem: Components using React Query need QueryClientProvider. --- Pattern: Custom Hook Testing --- Pattern: Mocking API Calls --- Pattern: Router Testing --- Pattern: Form Testing --- Pattern: Avoiding act() Warnings Problem: "Warning: An update inside a test was not wrapped in act(...)" --- Pattern: Snapshot Testing When to use: UI components with stable structure Design system components Components where visual regression matters When to avoid: Components with dynamic content Components that change frequently Large component trees (brittle) --- Pattern: Testing Context Providers --- Test Commands --- Common Issues Issue Solution ------- ---------- "Cannot find module" Check jest moduleNameMapper config act() warning Wrap state updates in act(), use waitFor/findBy Store state bleeding Add beforeEach with setState reset Async test timeout Increase timeout or check for hanging promises Mock not working Verify mock path matches import path exactly Query not found Use findBy for async content, check accessibility --- Recommended File Structure

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/react-testing

View the source on GitHub

Browse the @skills marketplace