More in Mobile Dev — page 3
How do you catch RN performance regressions?
WHAT IT TESTS: performance strategy and metrics. OUTLINE: track TTI, JS and UI thread FPS, and memory; baseline them and gate CI with automated tools like Flashlight, using the React profiler and DevTools to diagnose.
What are the key challenges of setting up Detox E2E?
WHAT IT TESTS: real-world E2E setup. OUTLINE: maintain separate debug/release build configs, rely on Detox automatic synchronization but tame uncontrolled async like timers and animations, and stabilize CI with headless emulators and retries.
RNTL or Detox for a navigation flow?
WHAT IT TESTS: choosing the right test level. OUTLINE: RNTL can test navigation logic by rendering the navigator in JS and asserting screen changes; Detox runs the real app for true end-to-end confidence including native transitions.
What does 'test behavior, not implementation' mean?
WHAT IT TESTS: testing philosophy. OUTLINE: query elements the way a user finds them (text, role, label) and assert observable behavior; for a Button, fire press and assert the visible effect, not internal state.
How do you test a component using a native module?
WHAT IT TESTS: handling native modules in Jest. OUTLINE: native code is absent in the Node-based Jest environment, so you mock the module with jest.mock to return fake values, often via the library's provided jest mock.
How do you mock a fetch call in Jest tests?
WHAT IT TESTS: deterministic network mocking. OUTLINE: replace global fetch with a Jest mock or a library like jest-fetch-mock, return a resolved Promise with a fake Response, and reset mocks between tests.
Unit testing vs component testing in React Native
WHAT IT TESTS: testing taxonomy. OUTLINE: unit tests verify isolated functions/logic with Jest; component tests render components and assert behavior with React Native Testing Library.
Why use a C++ TurboModule, and what are the risks?
WHAT IT TESTS: low-level native integration. OUTLINE: C++ JSI bindings give synchronous, serialization-free calls and shared cross-platform code; challenges are manual memory ownership across the JS-C++ boundary, GC interaction, and thread safety.
What do the spec file and CodeGen do in migration?
WHAT IT TESTS: migration mechanics. OUTLINE: the spec file declares the component's typed props and events; CodeGen reads it at build time to generate type-safe C++/native and JS glue, catching mismatches early.
What are the three pillars of the New Architecture?
WHAT IT TESTS: new architecture vocabulary. OUTLINE: JSI for direct JS-native calls, Fabric as the new renderer, and TurboModules for lazy native modules, all unified by CodeGen for type-safe bindings.
Direct events vs bubbling events in native components
WHAT IT TESTS: native UI event semantics. OUTLINE: direct events fire only on the originating component; bubbling events propagate up the component tree like the DOM, allowing parent capture.
Contrast the legacy bridge with JSI
WHAT IT TESTS: architectural comparison depth. OUTLINE: bridge is async, serialized JSON, and batched; JSI enables direct synchronous C++ calls with no serialization, cutting latency and enabling lazy native modules.
What data types cross the bridge, and their limits?
WHAT IT TESTS: bridge serialization limits. OUTLINE: only JSON-serializable types cross — strings, numbers, booleans, null, arrays, maps; functions and native object handles cannot. Handle complex data via ids, base64, or JSI host objects.
How do you send a one-off event from native to JS?
WHAT IT TESTS: native-to-JS communication basics. OUTLINE: emit an event from native using an event emitter and subscribe in JS with NativeEventEmitter, or resolve a promise/callback for a single result.
How do you debug a memory leak with Hermes heap snapshots?
WHAT IT TESTS: heap analysis workflow. OUTLINE: take a baseline snapshot, exercise the suspect flow repeatedly, snapshot again, and compare retained sizes and object counts that grow monotonically.
How do you move a 500ms blocking task off the JS thread?
WHAT IT TESTS: concurrency strategy in RN. OUTLINE: offload to a native module or C++ TurboModule, a worklet/worker thread, or chunk the work and yield; never block JS. RED FLAG: wrapping a synchronous loop in a Promise and assuming it stops blocking.
How do Fabric, TurboModules, and JSI fix bridge limits?
WHAT IT TESTS: deep knowledge of the new architecture. OUTLINE: JSI lets JS hold C++ host objects and call native synchronously without JSON serialization; Fabric renders concurrently and TurboModules lazy-load.
What is bridge traffic and what causes dropped frames?
WHAT IT TESTS: understanding the legacy async bridge. OUTLINE: the bridge passes batched, serialized JSON messages between JS and native asynchronously; high-frequency events flood it.
Which two Flipper plugins diagnose an unresponsive UI?
WHAT IT TESTS: practical profiling workflow. OUTLINE: use the React DevTools profiler to find expensive renders and the Performance/Hermes plugin to spot a blocked JS thread or low FPS.
What is Hermes and its advantages over JSC?
WHAT IT TESTS: knowledge of the JS engine powering RN. OUTLINE: Hermes is an open-source engine optimized for RN, with faster startup via precompiled bytecode and lower memory use. RED FLAG: claiming Hermes JITs or always beats JSC at peak throughput.