brew install node
Either install npm or check that you have it installed, using their official guide.
NOTE: For Detox, please use the latest
npmversion6.x.x(i.e not version 7.0.0 or newer).
npm install -g lerna@3.x.x
npm install -g react-native-cliFor all the internal projects (detox, detox-cli, demos, test) lerna will create symbolic links in node_modules instead of npm copying the content of the projects. This way, any change you do on any code is there immediately. There is no need to update node modules or copy files between projects.
gem install xcprettyAlternatively, run scripts/install.ios.sh / scripts/install.android.sh to install all prerequisites.
git clone git@github.com:wix/detox.git
cd detox
git submodule update --init --recursive(this makes sure all git submodule dependencies are properly checked out)
lerna bootstrapscripts/ci.ios.sh and scripts/ci.android.sh are the scripts Detox runs in CI, they will run lerna bootstrap, unit tests, and E2E tests. Make sure these scripts pass before submitting a PR, this is exactly what Detox is going to run in CI.
Alternatively, you can run it manually
Detox Android test project uses React Native sources instead of the precompiled AAR. The test project uses RN51 and RN53, both have issues with compilation (Fixed in RN55). In order to fix this issue, from inside detox/test run:
mv node_modules/react-native/ReactAndroid/release.gradle node_modules/react-native/ReactAndroid/release.gradle.baklerna run testDetox JS code is 100% test covered and is set to break the build if coverage gets below, so make sure you run unit tests (lerna run test) locally before pushing.
Alternatively, to run only the JS tests, run the following from the detox/detox directory:
npm run unit
-or-
npm run unit:watchAfter running the tests, jest will create a coverage report.
cd detox
open coverage/lcov-report/index.htmlDetox has a suite of e2e tests to test its own API while developing (and for regression); We maintain a special application that is "tested" against Detox's API, but essentially, it's the API that is tested, not the app.
To run the e2e tests, you must first build the native code and then run based on your target of choice (Android / iOS):
cd detox/test
npm run build:ios
npm run e2e:ioscd detox/test
npm run build:android
npm run e2e:androidAndroid test project includes two flavors:
fromBin - uses the precompiled aar from node_modules just like a standard RN project.
fromSource - compiles the project with RN sources from node_modules, this is useful when developing and debugging Espresso idle resource.
Here are the prerequisites to compiling React Native from source.
Each build can be triggered separately by running its assemble task:
./gradlew assembleFromSourceDebug or ./gradlew assembleFromBinDebug.
To run from Android Studio, React native react.gradle script requires node to be in path.
on macOS environment variables can be exported to desktop applications by adding the following to your .bashrc/.zshrc:
launchctl setenv PATH $PATHIf you add, rename, or delete a test in detox/test/e2e suite, you should follow these steps:
- In
detox/testproject, build the ios project withnpm run build:ios. - Run all end-to-end tests on iOS with
npm run e2e:ios. - In
detox/testproject, build the android project withnpm run build:android - Run all end-to-end tests on Android with
npm run e2e:android.
-
Install Java and Android SDK 25
-
In
detox/androidrun./gradlew installrun./gradlew test
Before you build one of example/demo-react-* projects for Android, you need to build Detox as an Android archive (a .aar file), locally:
cd detox
npm run build:androidOn success, the result is a set of maven artifacts published in subdirectories under
detox/Detox-android/. That includesdetox-999.999.999.aar(i.e. Detox' native code packaged with the fake version999.999.999).