testing-setup-react-native

Implements React Native component, screen, and hook tests using React Native Testing Library and Jest.

2|Updated Feb 14, 2026
One-click install
npx skills add https://github.com/Gamaroff/agent-skills --skill testing-setup-react-native-gamaroff
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-setup-react-native
Source: https://github.com/Gamaroff/agent-skills/tree/main/skills/testing-setup-react-native
Command: npx skills add https://github.com/Gamaroff/agent-skills --skill testing-setup-react-native-gamaroff

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @testing-library/react-native, jest, jest-expo.

What problem does it solve? Writing reliable tests for React Native apps is difficult due to native module dependencies, navigation hooks, and async rendering behavior. This Skill provides concrete patterns for testing components, screens, hooks, and user interactions without flaky failures or mock isolation bugs. ## Core Features & Use Cases - Component and Screen Testing: Patterns for testing UI components, Expo Router screens, and navigation flows with React Native Testing Library queries. - Native Module Mocking: Ready-made mock setups for AsyncStorage, Expo Router, Reanimated, and NetInfo. - Mock Isolation and Timing: Guidance on resetting mock implementations in beforeEach, setting up mocks before render, and using context-aware mockImplementation to fix suite-level test failures. - Use Case: A developer's auth-context tests pass individually but fail in the suite. Applying the beforeEach mock reset pattern raises the pass rate from 67% to 90%. ## Quick Start Use the testing-setup-react-native skill to write a test for my LoginForm component that mocks Expo Router and verifies form submission.

Frequently Asked Questions about testing-setup-react-native

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test React Native components with React Native Testing Library?▼

Render the component with render(), query elements using semantic queries like getByRole or getByText, and simulate interactions with fireEvent.press or fireEvent.changeText. Follow the Arrange-Act-Assert pattern and clear mocks in beforeEach.

How to mock Expo Router in Jest tests?▼

Mock expo-router with jest.mock, providing jest.fn() implementations for useRouter and useLocalSearchParams, and pass-through components for Stack and Tabs. Return push, back, and replace mocks from useRouter to assert navigation calls.

Why do React Native tests pass individually but fail in the suite?▼

jest.clearAllMocks() only clears call history, not mock implementations, so stale mockResolvedValue state leaks between tests. Reset every mock implementation to clean defaults in beforeEach to restore isolation.

Does React Native Testing Library support async data fetching tests?▼

Yes, use waitFor to wait for assertions or findBy queries that automatically wait for elements to appear after async operations. You can pass a custom timeout option to waitFor for slow operations.

When should I use testID instead of getByRole in React Native tests?▼

Use getByTestId only as a last resort when semantic queries like getByRole, getByLabelText, getByPlaceholderText, and getByText cannot locate the element. Semantic queries are preferred because they reflect accessibility behavior.