Skip to content

A minimal example of how to do integration testing in React Native.

Notifications You must be signed in to change notification settings

vikeri/rn-integration-tests

Repository files navigation

React Native Integration Testing

A minimal example of how to do integration testing in React Native.

Only iOS at the moment.

There are two kinds of integration tests

  1. Tests that are defined in Objective-C: IntegrationTestsObjC
  2. Tests that are defined in JS: IntegrationTestsJS

All the relevant test files are in two directories:

  • IntegrationTests: JS
  • ios/RNIntegrationTestExampleTests: Objective-C

The JS-tests are included in both JS and Objective-C

ios/RNIntegrationTestExampleTests/IntegrationTestsJS.m

56 // This list should be kept in sync with IntegrationTestsApp.js
57 RCT_TEST(IntegrationTestHarnessTest);
58 RCT_TEST(PassingTest);
59 // RCT_TEST(FailingTest);

IntegrationTests/IntegrationTestsApp.js

13 // Keep this list in sync with IntegrationTestsJS.m
14 var TESTS = [
15   require('./IntegrationTestHarnessTest'),
16   require('./PassingTest.js'),
17   require('./FailingTest.js'),
18 ];

Install

Requirements:

  • XCode
  • xctool (brew install xctool)
git clone https://github.com/vikeri/rnintegrationtestexample
cd RNIntegrationTestExample
npm install

Run tests

npm test

If you want to customize how the tests are run, edit the ./scripts/test

Develop tests

It might be easier to develop the tests inside React Native directly.

react-native run-ios

TODO

  • Run tests continuously, eg. rerun test with code change

Contribution

Yes please!

Pull requests and or discussions welcome.

License

MIT License

About

A minimal example of how to do integration testing in React Native.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published