| name | testing |
| description | Guidance for testing React Native code — unit tests for logic, component tests for behaviour, E2E for critical paths, and edge-case coverage. Use when adding tests, reviewing test quality, or setting a coverage bar. |
| version | 1.0.1 |
| platforms | ["ios","android"] |
| react-native-version | 0.76+ |
| tags | ["react-native","testing","quality"] |
Testing Skill
Applicability
- Platforms: iOS and Android
- React Native: 0.76+ (New Architecture interop assumed unless a checklist item says otherwise)
When to Use
- Adding tests for a new feature, hook, or utility
- Reviewing whether a change is adequately tested before merge
- Deciding what to test and at which level
- Investigating a regression that tests should have caught
Guidance
What to Test
How to Test
Incorrect:
expect(component.find('useFetchUsers')).toHaveBeenCalled();
Correct:
render(<UserList />);
expect(await screen.findByText('Ada Lovelace')).toBeOnTheScreen();
Pitfalls
- Snapshot tests fail on every harmless markup change, training the team to update them without reading — they catch little and erode trust.
- Over-mocking produces tests that pass while the real integration is broken; mock only what you must (network, native modules).
- Testing implementation details (which hook ran, internal state) makes refactoring painful even when behaviour is unchanged.
- Skipping edge cases (empty, error, offline) leaves the exact states users hit in production untested.