# Test React Native Apps Reliably

React Native tests often fail when native modules, stores, and async flows are not mocked consistently. This skill provides practical Jest and React Native Testing Library patterns.

## Install

```bash
npx skillstore add cjharmath/rn-testing
```

## Metadata

- Status: approved
- Slug: cjharmath-rn-testing
- Skillstore revision: r1
- Version status: missing
- Tree hash: d2e807be718222dbc8fcd075d57cd92c96c77d033a5028f2aafc00e84036f366
- Author: CJHarmath
- GitHub username: CJHarmath
- License: MIT
- Repository: https://github.com/CJHarmath/claude-agents-skills/tree/main/skills/rn-testing
- Ref: dd4a3ef9f20ddf38830950b4bb713df96b431fd6
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/cjharmath-rn-testing
- Manifest: https://skillstore.pages.dev/api/skills/cjharmath-rn-testing/manifest

## Capabilities

- Shows how to reset Zustand stores between tests with full-state replacement.
- Demonstrates async store testing with act and waitFor.
- Provides Jest mock patterns for Expo Router, SecureStore, Constants, and Haptics.
- Explains React Query test wrappers and retry-free query clients.
- Covers component, hook, navigation, API mock, and snapshot testing patterns.
- Lists common React Native test failures and direct fixes.

## Use Cases

- Stabilize Store Tests: Reset Zustand state and verify async actions without cross-test leakage.
- Mock Expo Modules: Create or review Jest mocks for routing, secure storage, constants, and haptics.
- Debug Test Failures: Resolve act warnings, module mapping errors, async timeouts, and brittle snapshots.

## Prompt Templates

### Write a Component Test

```
Show me how to test a React Native component with React Native Testing Library. Include event handling and async assertions.
```

### Test a Zustand Store

```
Help me write Jest tests for a Zustand store. Reset state before each test and verify async actions with act and waitFor.
```

### Review Flaky Tests

```
Review this React Native test suite for flaky async behavior, missing Expo mocks, and brittle snapshots. Suggest focused changes.
```

### Plan Feature Coverage

```
Design a testing strategy for a React Native feature that uses Expo Router, React Query, Zustand, and generated API hooks. Include mocks and assertions.
```

## Limitations

- It is a reference guide and does not create test files automatically.
- Examples assume Jest and React Native Testing Library are already configured.
- Project-specific imports, aliases, and mocks may need adjustment.
- It does not replace integration testing on real devices.

## Best Practices

- Reset shared store state before every test.
- Wait for async UI or store updates before asserting.
- Prefer behavior assertions over broad snapshots.

## Anti Patterns

- Do not rely on state left by previous tests.
- Do not snapshot dynamic lists or frequently changing screens.
- Do not duplicate mocks without checking global Jest setup.

## Security Audit

- Audited at: 2026-07-06T05:50:35.642\+00:00
- Summary: All 29 static findings were adjudicated as false positives. The matches are markdown code fences, inline references, documented npm test commands, a local mock URL, and Object.keys in a test assertion. No prompt injection, malicious intent, credential handling, or live network behavior was found in SKILL.md.

## Stats

- Views: 222
- Downloads: 9
- Favorites: 0
- Popularity score: 0
