Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improvements in setup of jest runner. Update GettingStarted documentation. #329

Merged
merged 3 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/Guide.Jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You should remove `e2e/mocha.opts`, you no longer need it.
### 3. Write a detox setup file

```js
// ./jest/setup/e2e.js
const detox = require('detox');
const config = require('../package.json').detox;

Expand All @@ -33,7 +34,6 @@ afterAll(async () => {
await detox.cleanup();
});

// optional, you may remove this part
beforeEach(async () => {
await device.reloadReactNative();
});
Expand All @@ -43,8 +43,12 @@ beforeEach(async () => {

Add this part to your `package.json`:
```json
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/jest/setup.js"
},
"scripts": {
"test:e2e": "jest e2e --setupTestFrameworkScriptFile=./jest/setup-e2e-tests.js --runInBand"
"test:e2e": "jest __e2e__ --setupTestFrameworkScriptFile=./jest/setup/e2e-tests.js --runInBand",
"test:e2e:build": "detox build"
}
```

Expand All @@ -59,5 +63,5 @@ 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 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
- 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
24 changes: 13 additions & 11 deletions docs/Introduction.GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ Homebrew is a package manager for macOS, we'll need it to install other command
#### 2. Install [Node.js](https://nodejs.org/en/)

Node is the JavaScript runtime Detox will run on. **Install Node 7.6.0 or above for native async-await support**

```sh
brew update && brew install node
brew update && brew install node
```

> TIP: Verify it works by typing in terminal `node -v` to output current node version, should be higher than 7.6.0

#### 3. Install [appleSimUtils](https://github.com/wix/AppleSimulatorUtils)
A collection of utils for Apple simulators, Detox uses it communicate with the simulator.

A collection of utils for Apple simulators, Detox uses it communicate with the simulator.

```sh
brew tap wix/brew
Expand Down Expand Up @@ -71,16 +71,18 @@ npm install detox --save-dev

#### 2. Install mocha

You can use any JavaScript test runner, [Mocha](https://mochajs.org/) is a good one we recommend:
You can use any JavaScript test runner
- [Jest](Guide.Jest.md)
- [Mocha](https://mochajs.org/) is a good one we recommend:

```sh
npm install mocha --save-dev
```
```

#### 3. Add Detox config to package.json

The basic configuration for Detox should be in your `package.json` file under the `detox` property:

```json
"detox": {
"configurations": {
Expand All @@ -90,10 +92,10 @@ The basic configuration for Detox should be in your `package.json` file under th
"type": "ios.simulator",
"name": "iPhone 7"
}
}
}
}
```

In the above configuration example, change `example` to your actual project name. Under the key `"binaryPath"`, `example.app` should be `<your_project_name>.app`. Under the key `"build"`, `example.xcodeproj` should be `<your_project_name>.xcodeproj` and `-scheme example` should be `-scheme <your_project_name>`.

For iOS apps in a workspace (eg: Cocoapods) use `-workspace ios/example.xcworkspace` instead of `-project`.
Expand Down Expand Up @@ -143,6 +145,6 @@ Use the Detox command line tools to test your project easily:
detox test
```

That's it. Your first failing Detox test is running!
That's it. Your first failing Detox test is running!

Next, we'll go over usage and how to make this test [actually pass](Introduction.WritingFirstTest.md).