Procházet zdrojové kódy

detox migration completed

Daniel Zlotin před 7 roky
rodič
revize
471071dab1

+ 117
- 119
playground/e2e/app.test.js Zobrazit soubor

@@ -1,173 +1,171 @@
1 1
 describe('app', () => {
2
-  beforeEach((done) => {
3
-    global.simulator.relaunchApp(done);
2
+  beforeEach(async () => {
3
+    await device.relaunchApp();
4 4
   });
5 5
 
6
-  it('shows welcome screen', () => {
7
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
6
+  it('shows welcome screen', async () => {
7
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
8 8
   });
9 9
 
10
-  it('switch to tab based app, passProps and functions', () => {
11
-    elementByLabel('Switch to tab based app').tap();
12
-    expect(elementByLabel('This is tab 1')).toBeVisible();
13
-    expect(elementByLabel('Hello from a function!')).toBeVisible();
10
+  it('switch to tab based app, passProps and functions', async () => {
11
+    await elementByLabel('Switch to tab based app').tap();
12
+    await expect(elementByLabel('This is tab 1')).toBeVisible();
13
+    await expect(elementByLabel('Hello from a function!')).toBeVisible();
14 14
   });
15 15
 
16
-  it('switch to tabs with side menus', () => {
17
-    elementByLabel('Switch to app with side menus').tap();
18
-    elementByLabel('This is a side menu center screen tab 1').swipe('right');
19
-    expect(elementByLabel('This is a left side menu screen')).toBeVisible();
16
+  it('switch to tabs with side menus', async () => {
17
+    await elementByLabel('Switch to app with side menus').tap();
18
+    await elementByLabel('This is a side menu center screen tab 1').swipe('right');
19
+    await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
20 20
   });
21 21
 
22
-  it('screen lifecycle', () => {
23
-    elementByLabel('Push lifecycle screen').tap();
24
-    expect(elementByLabel('onStart!')).toBeVisible();
25
-    elementByLabel('Push to test onStop').tap();
26
-    expect(elementByLabel('Alert')).toBeVisible();
27
-    expect(elementByLabel('onStop')).toBeVisible();
22
+  it('screen lifecycle', async () => {
23
+    await elementByLabel('Push lifecycle screen').tap();
24
+    await expect(elementByLabel('onStart!')).toBeVisible();
25
+    await elementByLabel('Push to test onStop').tap();
26
+    await expect(elementByLabel('Alert')).toBeVisible();
27
+    await expect(elementByLabel('onStop')).toBeVisible();
28 28
   });
29 29
 
30
-  it('unmount is called on pop', () => {
31
-    elementByLabel('Push lifecycle screen').tap();
32
-    expect(elementByLabel('onStart!')).toBeVisible();
33
-    element(by.traits(['button']).and(by.label('Back'))).tap();
34
-    expect(elementByLabel('onStop')).toBeVisible();
35
-    expect(elementByLabel('componentWillUnmount')).toBeVisible();
30
+  it('unmount is called on pop', async () => {
31
+    await elementByLabel('Push lifecycle screen').tap();
32
+    await expect(elementByLabel('onStart!')).toBeVisible();
33
+    await element(by.traits(['button']).and(by.label('Back'))).tap();
34
+    await expect(elementByLabel('onStop')).toBeVisible();
35
+    await expect(elementByLabel('componentWillUnmount')).toBeVisible();
36 36
   });
37 37
 });
38 38
 
39 39
 describe('screen stack', () => {
40
-  beforeEach((done) => {
41
-    global.simulator.relaunchApp(done);
40
+  beforeEach(async () => {
41
+    await device.relaunchApp();
42 42
   });
43 43
 
44
-  it('push screen', () => {
45
-    elementByLabel('Push').tap();
46
-    expect(elementByLabel('Pushed Screen')).toBeVisible();
44
+  it('push screen', async () => {
45
+    await elementByLabel('Push').tap();
46
+    await expect(elementByLabel('Pushed Screen')).toBeVisible();
47 47
   });
48 48
 
49
-  it('pop screen', () => {
50
-    elementByLabel('Push').tap();
51
-    expect(elementByLabel('Pushed Screen')).toBeVisible();
52
-    elementByLabel('Pop').tap();
53
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
49
+  it('pop screen', async () => {
50
+    await elementByLabel('Push').tap();
51
+    await expect(elementByLabel('Pushed Screen')).toBeVisible();
52
+    await elementByLabel('Pop').tap();
53
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
54 54
   });
55 55
 
56
-  it('pop screen deep in the stack', () => {
57
-    elementByLabel('Push').tap();
58
-    expect(elementByLabel('Stack Position: 1')).toBeVisible();
59
-    elementByLabel('Push').tap();
60
-    expect(elementByLabel('Stack Position: 2')).toBeVisible();
61
-    elementByLabel('Pop Previous').tap();
62
-    expect(elementByLabel('Stack Position: 2')).toBeVisible();
63
-    elementByLabel('Pop').tap();
64
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
56
+  it('pop screen deep in the stack', async () => {
57
+    await elementByLabel('Push').tap();
58
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
59
+    await elementByLabel('Push').tap();
60
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
61
+    await elementByLabel('Pop Previous').tap();
62
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
63
+    await elementByLabel('Pop').tap();
64
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
65 65
   });
66 66
 });
67 67
 
68 68
 describe('modal', () => {
69
-  beforeEach((done) => {
70
-    global.simulator.relaunchApp(done);
69
+  beforeEach(async () => {
70
+    await device.relaunchApp();
71 71
   });
72 72
 
73
-  it('show modal', () => {
74
-    elementByLabel('Show Modal').tap();
75
-    expect(elementByLabel('Modal Screen')).toBeVisible();
73
+  it('show modal', async () => {
74
+    await elementByLabel('Show Modal').tap();
75
+    await expect(elementByLabel('Modal Screen')).toBeVisible();
76 76
   });
77 77
 
78
-  it('dismiss modal', () => {
79
-    elementByLabel('Show Modal').tap();
80
-    expect(elementByLabel('Modal Screen')).toBeVisible();
81
-    elementByLabel('Dismiss Modal').tap();
82
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
78
+  it('dismiss modal', async () => {
79
+    await elementByLabel('Show Modal').tap();
80
+    await expect(elementByLabel('Modal Screen')).toBeVisible();
81
+    await elementByLabel('Dismiss Modal').tap();
82
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
83 83
   });
84 84
 
85
-  it('show multiple modals', () => {
86
-    elementByLabel('Show Modal').tap();
87
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
88
-    elementByLabel('Show Modal').tap();
89
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
90
-    elementByLabel('Dismiss Modal').tap();
91
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
92
-    elementByLabel('Dismiss Modal').tap();
93
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
85
+  it('show multiple modals', async () => {
86
+    await elementByLabel('Show Modal').tap();
87
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
88
+    await elementByLabel('Show Modal').tap();
89
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
90
+    await elementByLabel('Dismiss Modal').tap();
91
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
92
+    await elementByLabel('Dismiss Modal').tap();
93
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
94 94
   });
95 95
 
96
-  it('dismiss unknown screen id', () => {
97
-    elementByLabel('Show Modal').tap();
98
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
99
-    elementByLabel('Dismiss Unknown Modal').tap();
100
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
101
-    elementByLabel('Dismiss Modal').tap();
102
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
96
+  it('dismiss unknown screen id', async () => {
97
+    await elementByLabel('Show Modal').tap();
98
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
99
+    await elementByLabel('Dismiss Unknown Modal').tap();
100
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
101
+    await elementByLabel('Dismiss Modal').tap();
102
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
103 103
   });
104 104
 
105
-  it('dismiss modal by id which is not the top most', () => {
106
-    elementByLabel('Show Modal').tap();
107
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
108
-    elementByLabel('Show Modal').tap();
109
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
110
-    elementByLabel('Dismiss Previous Modal').tap();
111
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
112
-    elementByLabel('Dismiss Modal').tap();
113
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
105
+  it('dismiss modal by id which is not the top most', async () => {
106
+    await elementByLabel('Show Modal').tap();
107
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
108
+    await elementByLabel('Show Modal').tap();
109
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
110
+    await elementByLabel('Dismiss Previous Modal').tap();
111
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
112
+    await elementByLabel('Dismiss Modal').tap();
113
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
114 114
   });
115 115
 
116
-  it('dismiss all previous modals by id when they are below top presented modal', () => {
117
-    elementByLabel('Show Modal').tap();
118
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
119
-    elementByLabel('Show Modal').tap();
120
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
121
-    elementByLabel('Show Modal').tap();
122
-    expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
116
+  it('dismiss all previous modals by id when they are below top presented modal', async () => {
117
+    await elementByLabel('Show Modal').tap();
118
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
119
+    await elementByLabel('Show Modal').tap();
120
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
121
+    await elementByLabel('Show Modal').tap();
122
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
123 123
 
124
-    elementByLabel('Dismiss ALL Previous Modals').tap();
125
-    expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
124
+    await elementByLabel('Dismiss ALL Previous Modals').tap();
125
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
126 126
 
127
-    elementByLabel('Dismiss Modal').tap();
128
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
127
+    await elementByLabel('Dismiss Modal').tap();
128
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
129 129
   });
130 130
 
131
-  it('dismiss some modal by id deep in the stack', () => {
132
-    elementByLabel('Show Modal').tap();
133
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
134
-    elementByLabel('Show Modal').tap();
135
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
136
-    elementByLabel('Show Modal').tap();
137
-    expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
131
+  it('dismiss some modal by id deep in the stack', async () => {
132
+    await elementByLabel('Show Modal').tap();
133
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
134
+    await elementByLabel('Show Modal').tap();
135
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
136
+    await elementByLabel('Show Modal').tap();
137
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
138 138
 
139
-    elementByLabel('Dismiss First In Stack').tap();
140
-    expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
139
+    await elementByLabel('Dismiss First In Stack').tap();
140
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
141 141
 
142
-    elementByLabel('Dismiss Modal').tap();
143
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
142
+    await elementByLabel('Dismiss Modal').tap();
143
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
144 144
 
145
-    elementByLabel('Dismiss Modal').tap();
146
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
145
+    await elementByLabel('Dismiss Modal').tap();
146
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
147 147
   });
148 148
 
149
-  it('dismissAllModals', () => {
150
-    elementByLabel('Show Modal').tap();
151
-    expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
152
-    elementByLabel('Show Modal').tap();
153
-    expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
154
-    elementByLabel('Dismiss All Modals').tap();
155
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
149
+  it('dismissAllModals', async () => {
150
+    await elementByLabel('Show Modal').tap();
151
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
152
+    await elementByLabel('Show Modal').tap();
153
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
154
+    await elementByLabel('Dismiss All Modals').tap();
155
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
156 156
   });
157 157
 });
158 158
 
159
-describe('reload app', () => {
160
-  beforeEach((done) => {
161
-    simulator.reloadReactNativeApp(done);
159
+describe('reload app', async () => {
160
+  beforeEach(async () => {
161
+    await device.relaunchApp();
162 162
   });
163 163
 
164
-  it('push a screen to ensure its not there after reload', () => {
165
-    elementByLabel('Push').tap();
166
-    expect(elementByLabel('Pushed Screen')).toBeVisible();
167
-  });
168
-
169
-  it('show welcome screen after reload', () => {
170
-    expect(elementByLabel('React Native Navigation!')).toBeVisible();
164
+  it('push a screen to ensure its not there after reload', async () => {
165
+    await elementByLabel('Push').tap();
166
+    await expect(elementByLabel('Pushed Screen')).toBeVisible();
167
+    await device.reloadReactNative();
168
+    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
171 169
   });
172 170
 });
173 171
 

+ 13
- 12
playground/e2e/init.js Zobrazit soubor

@@ -1,19 +1,20 @@
1 1
 /*eslint-disable*/
2 2
 require('babel-polyfill');
3 3
 const detox = require('detox');
4
-const detoxConfig = require('../package.json').detox;
5 4
 
6
-detoxConfig['ios-simulator'].app = process.env.detoxAppBuildPath;
7
-
8
-before(function (done) {
9
-  detox.config(detoxConfig);
10
-  detox.start(done);
11
-});
12
-
13
-afterEach(function (done) {
14
-  detox.waitForTestResult(done);
5
+before(async () => {
6
+  const detoxConfig = {
7
+    configurations: {
8
+      ios: {
9
+        binaryPath: process.env.detoxAppBuildPath,
10
+        type: 'simulator',
11
+        name: 'iPhone 7'
12
+      }
13
+    }
14
+  }
15
+  await detox.init(detoxConfig);
15 16
 });
16 17
 
17
-after(function (done) {
18
-  detox.cleanup(done);
18
+after(async () => {
19
+  await detox.cleanup();
19 20
 });

+ 0
- 9
playground/package.json Zobrazit soubor

@@ -14,15 +14,6 @@
14 14
   },
15 15
   "//": "use react-native-navigation: 2.x.x --> we are manually installing it from a script for quicker workflow. Along with detox and shell-utils",
16 16
   "dependencies": {},
17
-  "detox": {
18
-    "session": {
19
-      "server": "ws://localhost:8099",
20
-      "sessionId": "playground"
21
-    },
22
-    "ios-simulator": {
23
-      "device": "iPhone 7"
24
-    }
25
-  },
26 17
   "babel": {
27 18
     "env": {
28 19
       "test": {

+ 1
- 2
playground/scripts/e2e.ios.js Zobrazit soubor

@@ -44,8 +44,7 @@ function e2e() { //eslint-disable-line
44 44
                               ./node_modules/mocha/bin/mocha e2e
45 45
                                 --timeout ${10 * 60 * 1000}
46 46
                                 --recursive
47
-                                --bail
48
-                                --compilers js:babel-register`);
47
+                                --bail`);
49 48
   } finally {
50 49
     shellUtils.exec.kill(`detox-server`);
51 50
     if (process.env.CI) {