A minimal example of how to do integration testing in React Native.
Only iOS at the moment.
There are two kinds of integration tests
- Tests that are defined in Objective-C: IntegrationTestsObjC
- Tests that are defined in JS: IntegrationTestsJS
All the relevant test files are in two directories:
IntegrationTests
: JSios/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 ];
Requirements:
- XCode
- xctool (
brew install xctool
)
git clone https://github.com/vikeri/rnintegrationtestexample
cd RNIntegrationTestExample
npm install
npm test
If you want to customize how the tests are run, edit the ./scripts/test
It might be easier to develop the tests inside React Native directly.
react-native run-ios
- Run tests continuously, eg. rerun test with code change
Yes please!
Pull requests and or discussions welcome.
MIT License