# Detox Plugin for Nx [![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]() [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fdetox.svg)](https://www.npmjs.com/@nrwl/detox) [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join us @nrwl/community on slack](https://img.shields.io/badge/slack-%40nrwl%2Fcommunity-brightgreen)](https://join.slack.com/t/nrwlcommunity/shared_invite/enQtNzU5MTE4OTQwOTk0LTgxY2E0ZWYzMWE0YzA5ZDA2MWM1NDVhNmI2ZWMyYmZhNWJiODk3MjkxZjY3MzU5ZjRmM2NmNWU1OTgyZmE4Mzc) ## Table of Contents - [Setup](#setup) - [Install applesimutils (Mac only)](#install-applesimutils-mac-only) - [Install Jest Globally](#install-jest-globally) - [Commands](#commands) - [Manually Add E2E Folder](#manually-add-e2e-folder) - [Change Testing Simulator/Emulator](#change-testing-simulatoremulator) - [Learn more](#learn-more) ## Setup #### Install applesimutils (Mac only) [applesimutils](https://github.com/wix/AppleSimulatorUtils) is a collection of utils for Apple simulators. ```sh brew tap wix/brew brew install applesimutils ``` #### Install Jest Globally ```sh npm install -g jest ``` ### Commands Note: For e2e tests to work, the app must be running (`nx start `). A built app must exist before run test commands. - `nx build-ios `: build the iOS app (Mac only) - `nx test-ios `: run e2e tests on the built iOS app (Mac only) - `nx build-ios --prod` and `nx test-ios --prod`: build and run release version of iOS app. Note: you might need open the xcode project under iOS and choose a team under "Sign & Capabilities". - `nx build-android `: build the android app - `nx test-android `: run e2e tests on the built android app - `nx build-android --prod` and `nx test-android --prod`: build and run release version of android app. ### Manually Add E2E Folder A `` folder is automatically generated when you create a react native app. However, if you want to add e2e folder manually, you need to: - Install @nrwl/detox ```sh # Using npm npm install --save-dev @nrwl/detox # Using yarn yarn add -D @nrwl/detox ``` - Run `nx generate @nrwl/detox:app ` - Follow instructions https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md to manully change android files. ### Change Testing Simulator/Emulator For iOS, in terminal, run `xcrun simctl list` to view a list of simulators on your Mac. To open your active simulator, `run open -a simulator`. In `/.detoxrc.json`, you could change the simulator under `devices.simulator.device`. For Android: in terminal, run `emulator -list-avds` to view a list of emulators installed. To open your emulator, run `emulator -avd `. In `/.detoxrc.json`, you could change the simulator under `devices.emulator.device`. To override the device name specified in a configuration, you could use `--device-name` option: `nx test-ios --device-name "iPhone 11"`. ## Learn more Visit the [Nx Documentation](https://nx.dev) to learn more.