name: rn-testing description: Automated testing for React Native mobile applications using Maestro, Detox, and Appium. Use when testing React Native apps, writing mobile test flows, running UI tests on iOS/Android, or automating mobile testing workflows. Covers framework selection (Maestro for simplicity, Detox for RN-native speed, Appium for cross-platform flexibility). tags: [react-native, mobile-testing, maestro, detox, appium]
React Native Testing
Test React Native mobile applications using Maestro, Detox, or Appium frameworks.
When to Use
- Testing React Native apps on iOS and Android
- Writing mobile UI test flows
- Running automated regression tests on mobile
- Debugging mobile app failures
- Automating mobile testing workflows
Framework Selection
New to mobile testing / AI agent workflow?
-> Maestro (simplest, YAML syntax)
React Native-only project with source code?
-> Detox (fastest for RN, automatic synchronization)
Multi-framework app or black-box testing?
-> Appium (most flexible, cross-platform)
| Framework | Syntax | Best For | Speed |
|---|---|---|---|
| Maestro | YAML | AI agents, quick tests | Medium |
| Detox | JavaScript/TypeScript | RN-native, gray-box | Fast |
| Appium | Python/JS/Java | Multi-framework, black-box | Slower |
Maestro (Recommended for AI Agents)
Create a Flow
appId: com.myapp
---
- launchApp
- tapOn: "Login"
- inputText: "user@example.com"
- tapOn: "Password Field"
- inputText: "password123"
- tapOn: "Submit"
- assertVisible: "Welcome Screen"
Use testID Props
<Button testID="login-button" title="Login" />
Reference in Maestro:
- tapOn:
id: "login-button"
Run Tests
# Single flow
maestro test flows/login.yaml
# Full suite
maestro test flows/
Common Scenarios
Form validation:
- tapOn: "Submit"
- assertVisible: "Error: Email required"
- tapOn:
id: "email-input"
- inputText: "user@example.com"
- tapOn: "Submit"
- assertNotVisible: "Error"
Navigation:
- launchApp
- tapOn: "Profile"
- assertVisible: "Profile Screen"
- back
- assertVisible: "Home Screen"
Detox
Prerequisites
- Detox CLI:
npm install -g detox-cli .detoxrc.jsconfiguration in project- App built:
detox build --configuration ios.sim.debug
Run Tests
# All tests
detox test --configuration ios.sim.debug
# Specific test
detox test --configuration android.emu.debug e2e/login.test.js
# Fast iteration (reuse existing install)
detox test --configuration ios.sim.debug --reuse --cleanup false
Appium
Requires Appium server running (appium).
# Start session
session = appium_start_session(platform="android", app_path="/path/to/app.apk")
# Find and interact
email = appium_find_element(session_id=sid, strategy="accessibility_id", value="email-input")
appium_input_text(session_id=sid, element_id=eid, text="user@example.com")
appium_tap(session_id=sid, element_id=submit_id)
Best Practices
- Use testIDs for stability -- text may change, testIDs persist
- Keep flows focused -- one scenario per file (login.yaml, checkout.yaml)
- Organize test files by feature:
flows/auth/,flows/checkout/,flows/navigation/ - Test critical paths first -- login, core flows, navigation, then edge cases
- Use descriptive assertions --
assertVisible: "Welcome, John!"notassertVisible: "Text 1"
File Organization
flows/
auth/
login.yaml
signup.yaml
logout.yaml
checkout/
add-to-cart.yaml
complete-order.yaml
navigation/
main-menu.yaml
Debugging Failed Tests
- Check test results for error details
- Common failures:
- Element not found -- verify testID, check if rendered, add timeout
- Timing issues -- Maestro/Detox handle automatically; Appium may need explicit waits
- Wrong configuration -- verify device running, app installed
Anti-Patterns
| Avoid | Why | Instead |
|---|---|---|
| Text-based selectors | Text changes break tests | Use testID props |
| Multiple concerns per flow | Hard to debug, slow | One scenario per file |
| Skipping critical paths | Login bugs block everything | Test login first |
| Hardcoded waits | Flaky, slow | Use framework sync (Maestro/Detox) |
Prerequisites Checklist
Maestro: CLI installed, emulator/simulator running, app installed
Detox: CLI installed, .detoxrc.js exists, app built for testing
Appium: Server installed and running, drivers installed, .apk/.app available
References
- Source: claude-skills/rn-testing (MIT License)
- Maestro Documentation
- Detox Documentation
- Appium Documentation