How would you split a React Native team's test budget across Jest, component tests and device E2E, and what would make you change the split?
answer
- cost per layer: seconds versus builds
- confidence where users get hurt
- OTA ships JavaScript without a new build
- escaped defects by layer
- flake rate and time to signal
basics
~20 sSpend most tests on fast Jest and component tests, keep device E2E to vital flows and native behaviour, and move the line when escaped bugs, flake rates, native churn or release channels show the current split is protecting the wrong things.
solid answer
~50 sStart from cost and blind spots. Jest and RNTL tests cost seconds and cover JavaScript logic and screen behaviour; device E2E costs native builds, booted simulators and triage, and is the only layer that sees native modules, layout and OS integration. So most tests sit in the fast layers and E2E covers vital flows such as sign-in and payment on both platforms. The split then follows evidence: bugs escaping from native code, upgrades or platform differences argue for more device coverage; a slow or flaky E2E suite that developers ignore argues for fewer, better device tests; frequent over-the-air JavaScript releases, which ship without a native rebuild or a new store submission, raise the bar for the fast layers that gate them. Review the split with escaped-defect data, flake rate and time to signal, not by gut.
go deeper
Recall that fast Jest and component tests make up most of a React Native suite, while device tests cover a few vital flows.
Explain the cost of each layer and which blind spots of the fast layers justify device tests.
Use escaped defects, flake rate and CI time to argue for moving specific tests between layers in a real project.
Own the test budget as a strategy: tie it to release channels, native surface area and platform risk, and revisit it on evidence rather than habit.
## The question behind the question Every React Native team has the same three layers: **pure Jest tests**, **component tests** with React Native Testing Library, and **device E2E** with Detox, Maestro or Appium. The judgement is not which layers exist but **how much to spend on each**. There is no single right ratio; a principal-level answer shows the cost model, the risk model and the signals that move the line. ## The cost model | Layer | Cost to run | Cost to maintain | What it proves | |---|---|---|---| | Pure Jest | Milliseconds per test, any CI machine | Low | Logic and data handling | | Component (RNTL) | Seconds per suite, any CI machine | Moderate: mocks must track native contracts | Screen behaviour in JavaScript | | Device E2E | Native build per platform, booted simulator or emulator, minutes per flow | High: device state, backend data, flake triage | The app working on a platform | Two costs are easy to miss. **Triage**: a flaky E2E test costs someone's afternoon each time it fails. **Trust**: once developers learn to re-run a red suite, it stops protecting anything. ## The risk model Spend where users get hurt and where cheap layers are blind: - **Vital flows** (sign-in, purchase, anything involving money or data loss) get device coverage on both platforms, as React Native's testing guide recommends for authentication, core functionality and payments. - **Native surface area** (custom native modules, heavy use of native libraries, platform-specific UI) raises the device share, because component tests only see mocks there. - **Pure product logic** (pricing, validation, state machines) is cheapest and most thoroughly covered in Jest. - **Screen behaviour** (states, errors, disabled buttons, accessibility labels) sits in RNTL. ## Release channels change the equation React Native apps can ship in two ways: 1. **A store build**, which rebuilds native code and passes store review. 2. **An over-the-air (OTA) update** of the JavaScript bundle and assets, which cannot change native code and does not go through a new native build or a new store submission. If the team ships OTA often, the fast layers are the main gate for most releases, so their quality bar rises: more component coverage of risky screens, stricter review of mocks. Device suites then concentrate on store builds and on changes that touch native code or dependencies. ## Signals that should move the split - **Escaped defects by layer.** Classify production bugs by the cheapest layer that could have caught them. Many native or layout bugs escaping means too little device coverage; many logic bugs escaping means the fast layers are thin. - **Flake rate.** A device suite failing without code changes more than rarely is a signal to shrink or stabilise it before adding tests. - **Time to signal.** If developers wait too long for feedback on a pull request, move E2E to merge or nightly runs and keep only a smoke flow per pull request. - **Upgrade pain.** React Native upgrades and native dependency bumps that break the app in ways Jest missed argue for a device smoke suite tied to those changes. - **Platform skew.** Bugs appearing on only one platform argue for running vital flows on both, not just the one developers use daily. ## A defensible starting point 1. Every pull request: all Jest and RNTL tests, plus one E2E smoke flow on one platform if builds are fast enough. 2. Merge to main: the vital-flow E2E suite on both platforms. 3. Release candidate: the E2E suite on a small set of real devices. 4. Quarterly: review escaped defects, flake rate and CI time, then move tests between layers. ## What a weak answer sounds like A fixed ratio recited without reasons, "E2E everything for confidence", or "we don't need E2E because coverage is 90 per cent". Coverage percentages measure JavaScript lines executed under mocks; they say nothing about the native half of the app.
- Your React Native team ships JavaScript-only fixes over the air weekly; how does that change what you test before a release?An OTA update replaces only the JavaScript bundle and assets, so no native rebuild or new store submission happens for it. The Jest and RNTL layers become the main gate for most releases, so strengthen component coverage of risky screens and keep mocks in step with native contracts. Reserve device suites for store builds and for any change that touches native code or dependencies.
- The device E2E suite fails randomly a few times a week and developers now re-run it by reflex; what do you do?Treat it as a broken gate: quarantine the flaky tests so the suite goes green only on real signal, find each flake's cause (live services, device state, timers, synchronisation) and fix or delete the test. Shrinking to a few reliable vital flows restores trust faster than adding more tests.
saying these in an interview costs you the question
- High Jest line coverage means the native side is covered too
- The right ratio of unit, component and E2E tests is fixed for every app
- More E2E tests always increase confidence
- OTA releases need no automated gate because they are only JavaScript
- Flaky E2E tests are fine as long as they are re-run until green