React Native

Testing

Ian VanSchooten

Sharing Code Across Platforms

Chris Cain

React Native Intro

Mobile app development with JavaScript

Not a hybrid app, runs actual native code

Learn once, write anywhere

Testing Challenges

Native Components cannot execute in Node.js

Targeting without CSS selectors 

RN Import resolution magic

Shim Native Components

Resolve require('react-native') to 'react'

Replace native components with React components that render null

Shim all RN APIs with empty functions

Targeting Without CSS

We use Enzyme React testing utilities

No CSS in React Native, how to target components?

Can still use className prop

Or the testId prop (great for Appium testing*)

* but not on Android ( issue)

RN Import resolution

require('path/img.png') -> path/img@2x.png

Use mockery to replace with a number (example)

component.android.js  &  component.ios.js

Set a platform env_var to control mocking

Sharing Code

Text

Text

Text

Text

Slide Title

Text

Text

Text

Text

Slide Title

Text

Text

Text

Text

React Native at Nutshell

By Ian VanSchooten

React Native at Nutshell

Lightning talk on testing and sharing code

  • 1,200