Skip to content

Mobile Testing

Ankit Upadhyay edited this page Jul 9, 2026 · 1 revision

Mobile: Testing

How the mobile app is tested. General strategy: Testing Strategy. Part of Mobile Overview.

Runner and layout

  • Jest 29 + Testing Library for React Native, config jest.config.js (RN 0.81 preset, @/src/, moduleNameMapper redirects for Amplify outputs, SVG/image/permissions/maps mocks). setupFiles: jest.setup-before-env.js; setupFilesAfterEnv includes RN's setup and a ~23 KB jest.setup.js of global mocks. collectCoverage: false by default (opt-in via --coverage), reporters lcov + text-summary, maxWorkers: '50%' (CI --maxWorkers=2), forceExit: true.
  • Tests live in the top-level __tests__/ tree mirroring src/: __tests__/components/{common,forms,tasks}, __tests__/features/<feature>/…, plus navigation/, screens/, services/, store/, hooks/, theme/, utils/, integration/, localization/, config/. Shared helpers in __tests__/setup/ (testUtils.tsx with a Redux/SafeArea/Navigation render wrapper, mockTheme.ts, globalMocks.ts) — that dir is ignored by testPathIgnorePatterns.

Coverage

Target ≥ 95% statements/branches/functions/lines; any touched file must not regress; new files must hit ≥ 90% on first commit (a process mandate in apps/mobileAppYC/AGENTS.md, not a hard coverageThreshold).

The known isolation / flake issue

Several suites render with raw react-test-renderer (ReactTestRenderer.create(<App/>) inside act(...)) rather than RTL — e.g. __tests__/App.test.tsx, integration/AppNavigator.integration.test.tsx, navigation/AuthNavigator.test.tsx, and some *.snapshot.test.tsx. These trees aren't auto-cleaned, so native timers/handles leak across tests; the config compensates with forceExit: true. The fix is unmounting/draining these raw renderer instances between tests — the root cause of #1822. Under Jest, App.tsx also swaps AsyncStorage for an in-memory storage.

Detox E2E

.detoxrc.js (Jest runner via e2e/jest.config.js, setupTimeout: 120000; iPhone 15 simulator / Pixel_7_API_34 emulator). Specs in e2e/ (smoke.e2e.js). Scripts: e2e:build:ios / e2e:ios / e2e:build:android / e2e:android. Detox runs separately, not in standard CI.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally