git clone [email protected]:wix/detox.git
cd detox
git submodule update --init --recursive
(this makes sure all git submodule dependencies are properly checked out)
brew install node
npm install -g lerna
npm install -g react-native-cli
For all the internal projects (detox, detox-server, 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.
brew tap facebook/fb
export CODE_SIGNING_REQUIRED=NO && brew install fbsimctl --HEAD
gem install xcpretty
lerna bootstrap
lerna run build
lerna run test
Detox 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:watch
After running the tests, jest will create a coverage report.
cd detox
open coverage/lcov-report/index.html
Detox has a suite of e2e tests to test its own API while developing (and for regression). The way we do is is by maintaining 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, go to detox/detox/test
cd detox/test
To build the application (if you already ran lerna run build
you're covered)
npm run build
To run the e2e tests, after the application was built.
npm run e2e
We are using a code generator based on babel
and objective-c-parser
to generate a Javascript Interface for EarlGrey
(the testing library we use on iOS).
This interface allows us to call Objective-C methods through the WebSocket connection directly on the testing device.
This approach is currently limited to GREYActions
, but we plan on extending it to cover more functionality of EarlGrey
.
You may see the generated files under detox/src/ios/earlgreyapi/
.
What happens under the hood can be seen in generation/
; it boils down to these steps for each input file:
- Convert Objective-C header file in a JSON Representation
- Build an Abstract Syntax Tree: Create Class & for each method
- Check if the type can be expressed simpler (
NSString *
=>NSString
) - Get the type checks for the arguments
- Get the return value
- Assemble type checks and return value to complete function
- Check if the type can be expressed simpler (
- Generate the code for the syntax tree & add helpers
If you would like to extend the code generation, please make sure to read the generation/README.md