-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add documentation for the usage with jest
Closes #143 Heavily inspired by the solution of @AlanFoster and with the help of @levito
- Loading branch information
Daniel Schmidt
committed
Oct 5, 2017
1 parent
dd32eb3
commit 60cdeac
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Jest as Test Runner | ||
|
||
## Usage | ||
|
||
### 0. Use the [Getting Started](Introduction.GettingStarted.md) Guide to set up detox | ||
|
||
Except that you need to skip the install mocha step. | ||
|
||
### 1. Install Jest | ||
|
||
```sh | ||
npm install --save-dev jest | ||
``` | ||
|
||
### 2. Remove mocha specific files | ||
|
||
You should remove `e2e/mocha.opts`, you no longer need it. | ||
|
||
### 3. Write a detox setup file | ||
|
||
```js | ||
const detox = require('detox'); | ||
const config = require('../package.json').detox; | ||
|
||
// Set the default timeout | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000; | ||
|
||
beforeAll(async () => { | ||
await detox.init(config); | ||
}); | ||
|
||
afterAll(async () => { | ||
await detox.cleanup(); | ||
}); | ||
|
||
// optional, you may remove this part | ||
beforeEach(async () => { | ||
await device.reloadReactNative(); | ||
}); | ||
``` | ||
|
||
### 4. Run jest | ||
|
||
```json | ||
{ | ||
... | ||
"scripts": { | ||
"test:e2e": "jest e2e --setupTestFrameworkScriptFile=./jest/setup-e2e-tests.js" | ||
} | ||
} | ||
``` | ||
|
||
|
||
> Side Note: Don't worry about mocks being used, detox works on the compiled version of your app. | ||
## How to run unit test and E2E tests in the same project | ||
|
||
- If you have a setup file for the unit tests pass it into jest by passing `--setupTestFrameworkScriptFile=./path/to/setup-unit-tests.js` to your jest unit test call. You need to remove this option from your `jest` configuration in the package.json. | ||
- Call your E2E tests like mentioned above |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters