Skip to content

Commit 6d9f412

Browse files
committed
chore(detox): clean up readme
1 parent ea23244 commit 6d9f412

File tree

1 file changed

+63
-61
lines changed

1 file changed

+63
-61
lines changed

packages/detox/README.md

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# NativeScript Detox
22

3-
Easily add [Detox](https://github.com/wix/Detox) end-to-end testing to your NativeScript apps!
3+
Easily add [Detox](https://github.com/wix/Detox) end-to-end testing to your NativeScript apps!
44

55
| <img src="https://i.imgur.com/apdbINz.gif" /> | <img src="https://i.imgur.com/mWBBF26.gif" /> |
6-
| --- | ----------- |
7-
| iOS Demo | Android Demo |
6+
| --------------------------------------------- | --------------------------------------------- |
7+
| iOS Demo | Android Demo |
88

99
---
1010

1111
## Table of Contents
12+
1213
1. [Installation](#installation)
1314
2. [Global Setup](#global-setup)
1415
3. [Project Setup](#project-setup)
@@ -18,7 +19,7 @@ Easily add [Detox](https://github.com/wix/Detox) end-to-end testing to your Nati
1819

1920
## Installation
2021

21-
```
22+
```bash
2223
ns plugin add @nativescript/detox
2324
```
2425

@@ -28,13 +29,13 @@ The full setup requirements can be found [here](https://github.com/wix/Detox/blo
2829

2930
### Install Detox command line tools (`detox-cli`)
3031

31-
```
32+
```bash
3233
npm install -g detox-cli
3334
```
3435

3536
### Install [applesimutils](https://github.com/wix/AppleSimulatorUtils) (iOS)
3637

37-
```
38+
```bash
3839
brew tap wix/brew
3940
brew install applesimutils
4041
```
@@ -43,28 +44,28 @@ brew install applesimutils
4344

4445
### Install the Detox package to your NativeScript project
4546

46-
```
47+
```bash
4748
npm install detox --save-dev
4849
```
4950

5051
### Install Jest
5152

52-
```
53+
```bash
5354
npm install jest jest-cli jest-circus --save-dev --no-package-lock
5455
```
5556

5657
### Initialize Detox
5758

58-
```
59+
```bash
5960
detox init -r jest
6061
```
6162

6263
If things go well, you should to have this set up:
6364

64-
* An `e2e/` folder in your project root
65-
* An `e2e/config.json` file; [example](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/config.json)
66-
* An `e2e/environment.js` file; [example](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/environment.js)
67-
* An `e2e/firstTest.e2e.js` file with content similar to [this](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/app-hello.e2e.js).
65+
- An `e2e/` folder in your project root
66+
- An `e2e/config.json` file; [example](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/config.json)
67+
- An `e2e/environment.js` file; [example](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/environment.js)
68+
- An `e2e/firstTest.e2e.js` file with content similar to [this](https://github.com/wix/Detox/blob/master/examples/demo-react-native-jest/e2e/app-hello.e2e.js).
6869

6970
There should also be a file called `.detoxrc.json` in your project root.
7071

@@ -74,42 +75,44 @@ Detox must be configued to know the location of the iOS and Android app binary a
7475

7576
Open `.detoxrc.json` and make the following modifications under `configurations` for iOS and Android.
7677

77-
* `binaryPath`: Specify the location of the app binary (probably something like below).
78-
* iOS: `platforms/ios/build/Debug-iphonesimulator/[APP_NAME].app`
79-
* Android: `platforms/android/app/build/outputs/apk/debug/app-debug.apk`
78+
- `binaryPath`: Specify the location of the app binary (probably something like below).
79+
80+
- iOS: `platforms/ios/build/Debug-iphonesimulator/[APP_NAME].app`
81+
- Android: `platforms/android/app/build/outputs/apk/debug/app-debug.apk`
8082

81-
* `build`: Specify the build command for iOS and Android.
82-
* iOS: `ns build ios`
83-
* Android: `ns build android --detox`
83+
- `build`: Specify the build command for iOS and Android.
8484

85-
* `device`:
86-
* iOS: `"type": "iPhone 11"`
87-
* Android: `"avdName": "Pixel_3a_API_30_1"` (use `emulator -list-avds` to list Android emulators)
85+
- iOS: `ns build ios`
86+
- Android: `ns build android --detox`
87+
88+
- `device`:
89+
- iOS: `"type": "iPhone 11"`
90+
- Android: `"avdName": "Pixel_3a_API_30_1"` (use `emulator -list-avds` to list Android emulators)
8891

8992
Here is a full example of a Detox configuration:
9093

9194
```json
9295
{
93-
"testRunner": "jest",
94-
"runnerConfig": "e2e/config.json",
95-
"configurations": {
96-
"ios": {
97-
"binaryPath": "platforms/ios/build/Debug-iphonesimulator/[APP_NAME].app",
98-
"build": "ns build ios",
99-
"type": "ios.simulator",
100-
"device": {
101-
"type": "iPhone 11"
102-
}
103-
},
104-
"android": {
105-
"binaryPath": "platforms/android/app/build/outputs/apk/debug/app-debug.apk",
106-
"build": "ns build android --detox",
107-
"type": "android.emulator",
108-
"device": {
109-
"avdName": "Pixel_3a_API_30_1"
110-
}
111-
}
112-
}
96+
"testRunner": "jest",
97+
"runnerConfig": "e2e/config.json",
98+
"configurations": {
99+
"ios": {
100+
"binaryPath": "platforms/ios/build/Debug-iphonesimulator/[APP_NAME].app",
101+
"build": "ns build ios",
102+
"type": "ios.simulator",
103+
"device": {
104+
"type": "iPhone 11"
105+
}
106+
},
107+
"android": {
108+
"binaryPath": "platforms/android/app/build/outputs/apk/debug/app-debug.apk",
109+
"build": "ns build android --detox",
110+
"type": "android.emulator",
111+
"device": {
112+
"avdName": "Pixel_3a_API_30_1"
113+
}
114+
}
115+
}
113116
}
114117
```
115118

@@ -123,13 +126,13 @@ Get started by opening the default test scenario in `e2e/firstTest.e2e.js`.
123126

124127
```javascript
125128
describe('Example', () => {
126-
beforeEach(async () => {
127-
await device.reloadReactNative();
128-
});
129+
beforeEach(async () => {
130+
await device.reloadReactNative();
131+
});
129132

130-
it('should have welcome screen', async () => {
131-
await expect(element(by.text('Sergio'))).toBeVisible();
132-
});
133+
it('should have welcome screen', async () => {
134+
await expect(element(by.text('Sergio'))).toBeVisible();
135+
});
133136
});
134137
```
135138

@@ -163,15 +166,15 @@ You should now be able to write tests to simulate user behavior and test for exp
163166

164167
Build your app for testing using the following command:
165168

166-
```
169+
```bash
167170
detox build -c ios|android
168171
```
169172

170173
### Testing
171174

172175
Run your tests with the folling command:
173176

174-
```
177+
```bash
175178
detox test -c ios|android
176179
```
177180

@@ -181,28 +184,27 @@ To make this even easier I would suggest adding these scripts to your `package.j
181184

182185
```json
183186
{
184-
"scripts": {
185-
...
186-
"e2e:android:build": "detox build -c android",
187-
"e2e:android:test": "detox test -c android && ./node_modules/.bin/enable-animations",
188-
"e2e:ios:build": "detox build -c ios",
189-
"e2e:ios:test": "detox test -c ios",
190-
...
191-
}
187+
"scripts": {
188+
"e2e:android:build": "detox build -c android",
189+
"e2e:android:test": "detox test -c android && ./node_modules/.bin/enable-animations",
190+
"e2e:ios:build": "detox build -c ios",
191+
"e2e:ios:test": "detox test -c ios"
192+
}
192193
}
193194
```
194195

195196
Now to build and run tests you would run:
196197

197198
Android:
198-
```
199+
200+
```bash
199201
npm run e2e:android:build
200202
npm run e2e:android:test
201203
```
202204

203205
iOS:
204206

205-
```
207+
```bash
206208
npm run e2e:ios:build
207209
npm run e2e:ios:test
208210
```
@@ -211,7 +213,7 @@ npm run e2e:ios:test
211213

212214
Detox requires a minimum SDK version of 18, so if you get the following error, change the `minSdkVersion` to 18 in `App_Resources/Android/app.gradle`.
213215

214-
```
216+
```bash
215217
Execution failed for task ':app:processDebugAndroidTestManifest'.
216218
Manifest merger failed : uses-sdk:minSdkVersion 17 cannot be smaller than version 18 declared in library [com.wix:detox:17.6.1] /Users/user/.gradle/caches/transforms-2/files-2.1/91a3acd87d710d1913b266ac114d7001/jetified-detox-17.6.1/AndroidManifest.xml as the library might be using APIs not available in 17
217219
Suggestion: use a compatible library with a minSdk of at most 17,

0 commit comments

Comments
 (0)