WhoBuilt

How Skyscanner Tests RN Bridges on iOS

Sep 14, 2018· 9 min· 55 views·Watch on YouTube

Speaker

Yoel Gluschnaider, a React Native developer at Skyscanner, explains how his five-person team tests native-to-JavaScript bridges for Skyscanner’s iOS app.

Why bridge testing matters

Skyscanner had more than 40 native developers and over 400 web developers, while Yoel’s team of five was integrating React Native into the existing app. The team needed bridges to reuse native services, analytics, and rendering, so testing those integrations was essential.

Limits of the standard integration test

The Facebook example runs a JavaScript test component from an iOS test and marks the run complete when the tests finish. Tests call one another in sequence, so adding or reordering tests can require linked-list-like changes. Xcode reports the suite as one result, and the run can fail if it takes longer than two minutes.

Problems with failures and setup

Yoel says a failure stops the suite, making it hard to identify individual failures and preventing later tests from running. Bridge tests also need native dependencies, such as authentication services, to be mocked. The standard setup makes it difficult to configure those preconditions separately for each test.

Run each JavaScript test separately

Skyscanner kept the same testing platform but passed each test’s method name and timeout to the JavaScript component as initial parameters. The component looks up and runs that method, while the native and JavaScript test methods share a name. This gives each test its own Xcode result, allows per-test setup and timeouts, and lets the rest of the suite continue after a failure.

Tradeoffs of the revised approach

The team has to keep the native and JavaScript method names in sync. The extra trips across the bridge may add a small performance cost, but Yoel considers that acceptable for isolated integration tests.

Takeaways

  • Test each bridge method as a separate case so failures are easier to locate.
  • Allow tests to keep running after one fails to collect more useful CI results.
  • Set mock dependencies and timeouts per test, especially when native services are involved.
  • Keep native and JavaScript test names aligned when dispatching tests through the bridge.

Mentioned in this talk

Search inside this talk

What was claimed 7

  • uses
    “over 400 web developers using React.js on the website”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Skyscanner integrates with React Native
    “integrating React Native into our existing application”
    YouTube
    Unverified1 source· Talk
  • metric
    integration testing: The original example requires completion within two minutes
    “You need to mark the test as completed within two minutes”
    YouTube
    Unverified1 source· Talk
  • feature
    Meta: Example iOS integration test for React Native bridge testing
    “the Facebook example: the simple integration test that you can find on the Facebook website”
    YouTube
    Unverified1 source· Talk
  • feature
    integration testing: Passes a JavaScript test method name, timeout, and individual preconditions from each native test
    “we pass three things: first, the test method name to run from JavaScript; second, a timeout”
    YouTube
    Unverified1 source· Talk
  • uses
    “we use the same platform, but we've tweaked it a little to make it easier for us to test and run in CI”
    YouTube
    Unverified1 source· Talk
  • feature
    Xcode: Displays the adapted bridge tests as separate methods with pass or fail indicators
    “For each individual test method in Xcode, we see an equivalent JavaScript command”
    YouTube
    Unverified1 source· Talk

Related talks