This guide describes how to install Mocha as a test runner to be used by Detox for running the E2E tests.
Note that while Mocha is lightweight and easy to set up, we nevertheless encourage usage of Jest instead, for 2 main reasons:
- Mocha does not support parallel-test execution (i.e. splitting the test suites between concurrently running test devices/emulators).
- Advanced integration features such as taking device screenshots on failures will not be as timely accurate as with working with Jest.
Disclaimer: Here we focus on installing Detox on new projects. If you're migrating a project with an existing Detox installation, please apply some common sense while using this guide.
Before starting with Mocha setup, be sure to complete the preliminary sections of the Getting Started guide.
npm install mocha --save-dev --no-package-lock
detox init -r mocha
Note: errors occurring in the process may appear in red.
If things go well, you should to have this set up: