Skyscanner Sep 28, 2017

Testing React Native iOS Bridges

Article Summary

Szabolcs Tóth from Skyscanner reveals how they solved a critical testing gap when integrating React Native into their Objective-C iOS app. Their solution transformed flaky, hard-to-debug bridge tests into a reliable testing framework.

Skyscanner chose to integrate React Native incrementally rather than rewrite their entire iOS app, which meant creating extensive native bridges. The team needed a way to ensure these bridges worked correctly without maintaining duplicate codebases or relying on manual testing of RN features.

Key Takeaways

Critical Insight

Skyscanner built a scalable integration testing framework that makes React Native bridge failures fast to identify and easy to debug through direct native-to-JS test mapping.

The article includes a clever runtime trick using synchronous network calls that automatically switches between local packager and bundled code without touching project settings.

About This Article

Problem

Skyscanner's logging system and core objects needed to work in React Native. Unit tests alone couldn't verify that JavaScript code could actually interact with native bridges without breaking things.

Solution

Szabolcs Tóth's team used RCTTestRunner and RCTTestModule to build integration tests. These tests run JavaScript test methods from native XCTestCase classes. They use bracket notation to dynamically call test methods by name based on parameters passed in.

Impact

The custom SKYRCTBridgeTestCase base class cut down boilerplate code across bridge modules. It also let teams set timeouts per test instead of using React Native's fixed two-minute default, so they got faster feedback when tests failed.