Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemmiz committed Nov 21, 2017
1 parent 138e4a0 commit d6bc068
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion detox/local-cli/detox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const program = require('commander');
const path = require('path');
const cp = require('child_process');
program
.option('-o, --runner-config [config]', 'Test runner config file')
.option('-o, --runner-config [config]', `Test runner config file, defaults to e2e/mocha.opts for mocha and e2e/config.json' for jest`)
.option('-l, --loglevel [value]', 'info, debug, verbose, silly, wss')
.option('-c, --configuration [device configuration]', 'Select a device configuration from your defined configurations,'
+ 'if not supplied, and there\'s only one configuration, detox will default to it')
Expand Down
24 changes: 18 additions & 6 deletions docs/APIRef.Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Detox can either initialize a server using a generated configuration, or can be
```

Session can also be set per configuration:

```json
"detox": {
...
Expand All @@ -58,19 +59,30 @@ Session can also be set per configuration:
}
```

### Test Root Folder

### Test Runner Configuration

##### Optional: setting a custom test root folder
Applies when using `detox-cli` by running `detox test` command, default is `e2e`.

##### Optional: setting a test runner (Mocha as default, Jest is supported)
##### Mocha
```json
"detox": {
...
"specs": "path/to/tests"
"test-runner": "mocha"
"runner-config": "path/to/mocha.opts"
"specs": "path/to/tests/root"
}
```
`mocha.opts` refers to `--opts` in https://mochajs.org/#mochaopts

##### Jest
```json
"detox": {
...
"test-runner": "jest"
"runner-config": "path/to/config.json"
}
```
`config.json` refers to `--config` in https://facebook.github.io/jest/docs/en/configuration.html
>NOTE: jest tests will run in band, as Detox does not currently supports parallelization.
## detox-cli
### Build Configuration
Expand Down
3 changes: 1 addition & 2 deletions docs/APIRef.DetoxCLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Initiating your test suite
| Option| Description |
| --- | --- |
| -h, --help | output usage information |
| -r, --runner [runner] | Test runner (supports mocha and jest) |
| -o, --runner-config \<config\> | Test runner config file |
| -o, --runner-config \<config\> | Test runner config file, defaults to 'e2e/mocha.opts' for mocha and 'e2e/config.json' for jest |
| -l, --loglevel [value] | info, debug, verbose, silly, wss |
| -c, -configuration \<device config\> | Select a device configuration from your defined figurations,if not supplied, and there's only one configuration, detox will default to it |
| -r, --reuse | Reuse existing installed app (do not delete and re-tall) for a faster run. |
Expand Down
24 changes: 14 additions & 10 deletions docs/Guide.Jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,29 @@ beforeAll(async () => {
afterAll(async () => {
await detox.cleanup();
});
```

beforeEach(async () => {
await device.reloadReactNative();
});
### 4. Configure Detox to run with Jest

Add a Jest config file `e2e/config.json`:

```json
{
"setupTestFrameworkScriptFile" : "./init.js"
}
```

### 4. Run jest

Add this part to your `package.json`:
In `package.json`:

```json
"jest": {
"setupTestFrameworkScriptFile": "./e2e/init.js"
},
"scripts": {
"test:e2e": "detox test -c ios.sim.debug",
"test:e2e:build": "detox build"
},
"detox": {
"runner": "jest",
"test-runner": "jest",
"runner-config": "e2e/config.json"
...
}
```
Expand All @@ -65,4 +69,4 @@ There are some things you should notice:
## How to run unit test and E2E tests in the same project

- If you have a setup file for the unit tests pass `./jest/setup` implementation into your unit setup.
- Call your E2E tests like mentioned above
- Call your E2E tests using `detox-cli`: `detox test`
2 changes: 1 addition & 1 deletion examples/demo-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react-native": "0.44.0"
},
"devDependencies": {
"mocha": "^3.2.0",
"mocha": "^4.0.1",
"detox": "^5.0.0"
},
"detox": {
Expand Down

0 comments on commit d6bc068

Please sign in to comment.