WhoBuilt

Visual Regression Testing in React Native

Sep 27, 2022· 19 min· 1.8K views·Watch on YouTube

Speaker

Rob Walker, a senior software engineer at Formidable, explains visual regression testing in React Native at React Native EU 2022, hosted by Callstack.

Why visual regressions slip through

Walker describes a shopping cart broken by a broad search-and-replace made while styling the login screen. The tests passed and reviewers missed the issue, showing how a change in one part of an app can affect another.

What different tests can catch

Visual regression testing compares screenshots of the rendered app against committed baselines, covering layouts, styles, images, text, and user flows. Manual testing is flexible but time-consuming and can miss small changes; Jest snapshots are quick but usually check components in isolation rather than how a full screen or flow behaves.

A subtle bug and React Native Owl

In Walker’s shopping cart example, overscrolling leaves a payment button partly hidden behind a fixed checkout button. Component snapshots may not catch the interaction, while a screenshot taken after scrolling can reveal it. React Native Owl provides a CLI, Jest matcher, simulator interaction API, and report generator for running these checks.

Running tests and reviewing changes

Walker’s demo builds an app for iOS or Android, takes screenshots as it navigates through screens, and compares them with baselines. A report shows passing screenshots or highlights differences, including small text changes. When a change is intentional, the baseline can be updated with a test flag and committed for future comparisons.

Using diffs in pull requests

Running visual tests in a pull request can catch an unintended change before merge and show reviewers what changed. Updated baseline images also let reviewers compare before and after visuals in GitHub without launching the app. Walker notes that Detox can capture screenshots for a similar comparison workflow.

Takeaways

  • Pair component snapshots with screenshot checks for rendered screens and multi-step flows.
  • Include interaction states such as the bottom of a scrolled view, where layout conflicts can appear.
  • Commit reviewed baseline screenshots so CI can compare future runs against a known state.
  • Treat baseline updates as reviewable changes: inspect the before and after images before merging.
  • Consider CI setup and simulator reliability when deciding how broadly to run visual tests.

Mentioned in this talk

Search inside this talk

What was claimed 6

  • role at
    Rob Walker is senior software engineer at Formidable
    “I am a senior software engineer at Formidable.”
    YouTube
    Unverified1 source· Talk
  • feature
    React Native Owl: Provides a CLI to build and run apps for tests, a custom Jest matcher for screenshot comparisons, an interaction API, and a report generator.
    “There's a really small CLI ... a custom Jest matcher ... an interaction API ... and then there's a report generator.”
    YouTube
    Unverified1 source· Talk
  • uses
    “There's a custom Jest matcher, which is used to compare the screenshots”
    YouTube
    Unverified1 source· Talk
  • uses
    “we're using Infinite Red's Ignite bootstrap to get a demo app working”
    YouTube
    Unverified1 source· Talk
  • feature
    Cypress: Has visual regression testing extensions for web-based React.
    “Cypress, which has several visual regression testing extensions”
    YouTube
    Unverified1 source· Talk
  • feature
    Detox: Can take screenshots that can be used for image comparison or diffing.
    “You can take screenshots with Detox”
    YouTube
    Unverified1 source· Talk

Related talks