Mobile App Testing Patterns
Your React Native app works flawlessly on the iPhone 15 Pro sitting on your desk. Then the crash reports roll in: Android 12 on Samsung Galaxy A13, iOS 16 on iPhone SE (2nd gen), and a tablet layout that overlaps every text element. Mobile testing is a combinatorial explosion — dozens of devices, multiple OS versions, varying screen sizes, and platform-specific behaviors. AI tools cannot test on every device, but they can generate the tests that cover the most ground.
What You’ll Walk Away With
Section titled “What You’ll Walk Away With”- Cross-platform test generation for React Native and Flutter applications
- Device matrix strategies that maximize coverage without testing every permutation
- Platform-specific testing patterns for gestures, navigation, and permissions
- Responsive layout testing across screen sizes and orientations
- AI prompts for generating Detox and Maestro test suites
Cross-Platform Test Generation
Section titled “Cross-Platform Test Generation”Generate Detox E2E tests for our React Native app's onboarding flow:
Flow: Splash -> Welcome -> Permission Requests -> Profile Setup -> Home
1. Splash screen: Verify logo displays, auto-navigates after 2 seconds2. Welcome: Swipe through 3 carousel pages, tap "Get Started"3. Permissions: Handle push notification permission dialog (allow and deny paths)4. Profile: Fill name, select avatar, tap "Complete"5. Home: Verify the user name appears, main navigation tabs are visible
Platform-specific handling:- iOS: Use system dialog matchers for permission requests- Android: Use UiAutomator for permission dialogs
Test both:- Happy path (all permissions granted)- Permissions denied path (verify graceful degradation)- Back navigation at each step
Save to /e2e/onboarding.e2e.tsclaude "Create a comprehensive Detox test suite for our React Native app:
1. Analyze the navigation structure in /src/navigation/2. Generate E2E tests for each user flow: - Onboarding (first launch experience) - Authentication (login, signup, password reset) - Core feature (main product interaction) - Settings (profile edit, preferences, logout)
3. For each test: - Handle both iOS and Android platform differences - Include proper device synchronization waits - Test both portrait and landscape orientations - Handle system dialogs (permissions, alerts)
4. Create test utilities: - /e2e/utils/auth.ts (login/logout helpers) - /e2e/utils/permissions.ts (grant/deny system permissions) - /e2e/utils/navigation.ts (navigation state helpers)
Run on iOS simulator first, then verify Android compatibility."Generate mobile E2E tests for this React Native application:1. Analyze the app's navigation and screens2. Create Detox tests for all critical user flows3. Handle platform-specific differences (iOS vs Android)4. Run tests on both platforms and fix any failures5. Create a PR with the test suite
Include a device matrix configuration for CI.Device Matrix Strategy
Section titled “Device Matrix Strategy”You cannot test on every device. Choose strategically.
Platform-Specific Testing
Section titled “Platform-Specific Testing”Gesture and Interaction Testing
Section titled “Gesture and Interaction Testing”Responsive Layout Testing
Section titled “Responsive Layout Testing”Offline and Network Testing
Section titled “Offline and Network Testing”When This Breaks
Section titled “When This Breaks”“Detox tests pass on simulator but fail on real devices.” Simulators and emulators do not perfectly replicate real device behavior. Gestures, performance, and system dialogs behave differently. Run critical path tests on at least one real device through a cloud service (BrowserStack, AWS Device Farm).
“Tests are flaky due to animation timing.” Mobile animations cause timing issues. Disable animations in test builds (UIView.setAnimationsEnabled(false) on iOS, Settings > Developer options > Animation scale 0x on Android) or use Detox’s synchronization.
“Android tests behave differently across manufacturers.” Samsung, Xiaomi, and OnePlus add custom UI layers that affect system dialogs and navigation. Test on the top 3 manufacturers in your analytics, not just the stock Pixel emulator.
“Our CI is too slow for mobile tests.” Mobile test suites are inherently slower than web tests. Run smoke tests (3-5 critical flows) on every PR and the full suite nightly. Use cloud device farms for parallel execution.