All Projects → vikeri → rn-integration-tests

vikeri / rn-integration-tests

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

Programming Languages

objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
shell
77523 projects

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].