# Build Reliable React Native Tests

React Native test setup and failures can slow feature delivery. This skill provides focused Jest and React Native Testing Library patterns for creating, running, and debugging tests.

## Install

```bash
npx skillstore add babakbar/mobile-testing
```

## Metadata

- Status: approved
- Slug: babakbar-mobile-testing
- Skillstore revision: r3
- Version status: missing
- Tree hash: f7bacdf5b0d6b57b80294a5a70c661105191489238cae936f5c540a9946aa835
- Author: BabakBar
- GitHub username: BabakBar
- License: MIT
- Repository: https://github.com/BabakBar/VibeKeeper/tree/main/.claude/skills/testing
- Ref: 80999bf530a7874d7bedf8ce202001ecb4c4f5e0
- 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: 76
- Public page: https://skillstore.pages.dev/skills/babakbar-mobile-testing
- Manifest: https://skillstore.pages.dev/api/skills/babakbar-mobile-testing/manifest

## Capabilities

- Sets up Jest scripts and React Native Testing Library dependencies.
- Provides component test templates for rendered text and press events.
- Provides hook and utility test templates.
- Shows mocks for notifications, database clients, and navigation.
- Explains commands for test runs, watch mode, coverage, snapshots, and selected files.
- Offers troubleshooting guidance for timeouts, queries, mocks, and asynchronous tests.

## Use Cases

- Add a component test: Create a test for visible content and a button press in a React Native component.
- Debug a failing test: Use the troubleshooting patterns to investigate timeouts, missing elements, mocks, and asynchronous behavior.
- Standardize test practices: Apply the templates and best practices when introducing a consistent test approach to a mobile codebase.

## Prompt Templates

### Beginner: create a component test

```
Create a Jest test for my React Native Button component. Test that its label renders and its onPress handler runs once.
```

### Intermediate: test a hook

```
Write a React Native Testing Library test for my useCounter hook. Test its initial count and increment behavior.
```

### Advanced: mock dependencies

```
Help me test a React Native screen that uses expo-router and a database client. Create focused Jest mocks and explain where to place them.
```

### Advanced: diagnose asynchronous failure

```
My React Native test times out while waiting for loaded content. Review this test flow and suggest a reliable waitFor or findBy strategy.
```

## Limitations

- Focuses on Jest and React Native Testing Library, not device-level end-to-end testing.
- Does not configure a specific application or inspect its existing test setup.
- Mock examples may need changes for a project’s aliases, libraries, and architecture.
- Does not replace testing on physical devices or emulators.

## Best Practices

- Test user-visible behavior instead of internal implementation details.
- Mock external dependencies to keep tests isolated and predictable.
- Use asynchronous queries when the interface updates after an operation.

## Anti Patterns

- Do not rely on implementation-specific state or private component methods.
- Do not leave unresolved promises or timers in asynchronous tests.
- Do not use broad mocks that hide important application behavior.

## Security Audit

- Audited at: 2026-07-18T10:16:59.708\+00:00
- Summary: All 30 static findings are false positives. The external-command detections match Markdown formatting and local test commands, while the URLs are documentation links. No prompt injection, data exfiltration, or unsafe execution intent was found in SKILL.md.

## Stats

- Views: 224
- Downloads: 15
- Favorites: 0
- Popularity score: 0
