@appium/base-driver 8.2.4 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/build/lib/basedriver/capabilities.d.ts +80 -0
  2. package/build/lib/basedriver/capabilities.d.ts.map +1 -0
  3. package/build/lib/basedriver/capabilities.js +12 -13
  4. package/build/lib/basedriver/commands/event.d.ts +9 -0
  5. package/build/lib/basedriver/commands/event.d.ts.map +1 -0
  6. package/build/lib/basedriver/commands/event.js +21 -23
  7. package/build/lib/basedriver/commands/find.d.ts +11 -0
  8. package/build/lib/basedriver/commands/find.d.ts.map +1 -0
  9. package/build/lib/basedriver/commands/find.js +41 -43
  10. package/build/lib/basedriver/commands/index.d.ts +8 -0
  11. package/build/lib/basedriver/commands/index.d.ts.map +1 -0
  12. package/build/lib/basedriver/commands/index.js +17 -16
  13. package/build/lib/basedriver/commands/log.d.ts +12 -0
  14. package/build/lib/basedriver/commands/log.d.ts.map +1 -0
  15. package/build/lib/basedriver/commands/log.js +23 -30
  16. package/build/lib/basedriver/commands/session.d.ts +11 -0
  17. package/build/lib/basedriver/commands/session.d.ts.map +1 -0
  18. package/build/lib/basedriver/commands/session.js +21 -158
  19. package/build/lib/basedriver/commands/settings.d.ts +10 -0
  20. package/build/lib/basedriver/commands/settings.d.ts.map +1 -0
  21. package/build/lib/basedriver/commands/settings.js +18 -22
  22. package/build/lib/basedriver/commands/timeout.d.ts +8 -0
  23. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -0
  24. package/build/lib/basedriver/commands/timeout.js +118 -144
  25. package/build/lib/basedriver/core.d.ts +235 -0
  26. package/build/lib/basedriver/core.d.ts.map +1 -0
  27. package/build/lib/basedriver/core.js +283 -0
  28. package/build/lib/basedriver/desired-caps.d.ts +5 -0
  29. package/build/lib/basedriver/desired-caps.d.ts.map +1 -0
  30. package/build/lib/basedriver/desired-caps.js +2 -4
  31. package/build/lib/basedriver/device-settings.d.ts +32 -0
  32. package/build/lib/basedriver/device-settings.d.ts.map +1 -0
  33. package/build/lib/basedriver/device-settings.js +33 -15
  34. package/build/lib/basedriver/driver.d.ts +83 -0
  35. package/build/lib/basedriver/driver.d.ts.map +1 -0
  36. package/build/lib/basedriver/driver.js +104 -257
  37. package/build/lib/basedriver/helpers.d.ts +132 -0
  38. package/build/lib/basedriver/helpers.d.ts.map +1 -0
  39. package/build/lib/basedriver/helpers.js +24 -10
  40. package/build/lib/basedriver/logger.d.ts +3 -0
  41. package/build/lib/basedriver/logger.d.ts.map +1 -0
  42. package/build/lib/basedriver/logger.js +2 -4
  43. package/build/lib/constants.d.ts +9 -0
  44. package/build/lib/constants.d.ts.map +1 -0
  45. package/build/lib/constants.js +2 -4
  46. package/build/lib/express/crash.d.ts +3 -0
  47. package/build/lib/express/crash.d.ts.map +1 -0
  48. package/build/lib/express/crash.js +2 -4
  49. package/build/lib/express/express-logging.d.ts +3 -0
  50. package/build/lib/express/express-logging.d.ts.map +1 -0
  51. package/build/lib/express/express-logging.js +3 -5
  52. package/build/lib/express/idempotency.d.ts +2 -0
  53. package/build/lib/express/idempotency.d.ts.map +1 -0
  54. package/build/lib/express/idempotency.js +3 -5
  55. package/build/lib/express/logger.d.ts +3 -0
  56. package/build/lib/express/logger.d.ts.map +1 -0
  57. package/build/lib/express/logger.js +2 -4
  58. package/build/lib/express/middleware.d.ts +9 -0
  59. package/build/lib/express/middleware.d.ts.map +1 -0
  60. package/build/lib/express/middleware.js +2 -4
  61. package/build/lib/express/server.d.ts +10 -0
  62. package/build/lib/express/server.d.ts.map +1 -0
  63. package/build/lib/express/server.js +2 -4
  64. package/build/lib/express/static.d.ts +6 -0
  65. package/build/lib/express/static.d.ts.map +1 -0
  66. package/build/lib/express/static.js +2 -4
  67. package/build/lib/express/websocket.d.ts +64 -0
  68. package/build/lib/express/websocket.d.ts.map +1 -0
  69. package/build/lib/express/websocket.js +2 -4
  70. package/build/lib/helpers/capabilities.d.ts +13 -0
  71. package/build/lib/helpers/capabilities.d.ts.map +1 -0
  72. package/build/lib/helpers/capabilities.js +77 -0
  73. package/build/lib/index.d.ts +183 -0
  74. package/build/lib/index.d.ts.map +1 -0
  75. package/build/lib/index.js +41 -25
  76. package/build/lib/jsonwp-proxy/protocol-converter.d.ts +48 -0
  77. package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -0
  78. package/build/lib/jsonwp-proxy/protocol-converter.js +19 -15
  79. package/build/lib/jsonwp-proxy/proxy.d.ts +41 -0
  80. package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -0
  81. package/build/lib/jsonwp-proxy/proxy.js +20 -15
  82. package/build/lib/jsonwp-status/status.d.ts +159 -0
  83. package/build/lib/jsonwp-status/status.d.ts.map +1 -0
  84. package/build/lib/jsonwp-status/status.js +2 -4
  85. package/build/lib/protocol/errors.d.ts +310 -0
  86. package/build/lib/protocol/errors.d.ts.map +1 -0
  87. package/build/lib/protocol/errors.js +82 -5
  88. package/build/lib/protocol/helpers.d.ts +22 -0
  89. package/build/lib/protocol/helpers.d.ts.map +1 -0
  90. package/build/lib/protocol/helpers.js +2 -4
  91. package/build/lib/protocol/index.d.ts +16 -0
  92. package/build/lib/protocol/index.d.ts.map +1 -0
  93. package/build/lib/protocol/index.js +8 -10
  94. package/build/lib/protocol/protocol.d.ts +11 -0
  95. package/build/lib/protocol/protocol.d.ts.map +1 -0
  96. package/build/lib/protocol/protocol.js +38 -35
  97. package/build/lib/protocol/routes.d.ts +6 -0
  98. package/build/lib/protocol/routes.d.ts.map +1 -0
  99. package/build/lib/protocol/routes.js +84 -4
  100. package/build/lib/protocol/validators.d.ts +8 -0
  101. package/build/lib/protocol/validators.d.ts.map +1 -0
  102. package/build/lib/protocol/validators.js +2 -4
  103. package/build/test/basedriver/README.md +5 -0
  104. package/build/test/basedriver/driver-e2e-tests.js +2 -4
  105. package/build/test/basedriver/driver-tests.js +41 -19
  106. package/build/test/basedriver/index.js +2 -4
  107. package/build/test/e2e/basedriver/driver.e2e.spec.js +15 -0
  108. package/build/test/e2e/basedriver/helpers.e2e.spec.js +192 -0
  109. package/build/test/e2e/basedriver/websockets.e2e.spec.js +82 -0
  110. package/build/test/e2e/express/server.e2e.spec.js +159 -0
  111. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +59 -0
  112. package/build/test/e2e/protocol/fake-driver.js +163 -0
  113. package/build/test/e2e/protocol/helpers.js +25 -0
  114. package/build/test/e2e/protocol/protocol.e2e.spec.js +1186 -0
  115. package/build/test/helpers.js +2 -4
  116. package/build/test/unit/basedriver/capabilities.spec.js +672 -0
  117. package/build/test/unit/basedriver/capability.spec.js +353 -0
  118. package/build/test/unit/basedriver/commands/event.spec.js +110 -0
  119. package/build/test/unit/basedriver/commands/log.spec.js +92 -0
  120. package/build/test/unit/basedriver/driver.spec.js +15 -0
  121. package/build/test/unit/basedriver/helpers.spec.js +151 -0
  122. package/build/test/unit/basedriver/timeout.spec.js +135 -0
  123. package/build/test/unit/express/server.spec.js +155 -0
  124. package/build/test/unit/express/static.spec.js +26 -0
  125. package/build/test/unit/jsonwp-proxy/mock-request.js +91 -0
  126. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +171 -0
  127. package/build/test/unit/jsonwp-proxy/proxy.spec.js +292 -0
  128. package/build/test/unit/jsonwp-proxy/url.spec.js +165 -0
  129. package/build/test/unit/jsonwp-status/status.spec.js +34 -0
  130. package/build/test/unit/protocol/errors.spec.js +390 -0
  131. package/build/test/unit/protocol/routes.spec.js +80 -0
  132. package/build/test/unit/protocol/validator.spec.js +149 -0
  133. package/build/tsconfig.tsbuildinfo +1 -0
  134. package/lib/basedriver/capabilities.js +49 -10
  135. package/lib/basedriver/commands/event.js +49 -31
  136. package/lib/basedriver/commands/find.js +107 -45
  137. package/lib/basedriver/commands/index.js +25 -19
  138. package/lib/basedriver/commands/log.js +59 -34
  139. package/lib/basedriver/commands/session.js +39 -142
  140. package/lib/basedriver/commands/settings.js +32 -14
  141. package/lib/basedriver/commands/timeout.js +153 -154
  142. package/lib/basedriver/core.js +497 -0
  143. package/lib/basedriver/desired-caps.js +1 -1
  144. package/lib/basedriver/device-settings.js +57 -13
  145. package/lib/basedriver/driver.js +277 -375
  146. package/lib/basedriver/helpers.js +31 -13
  147. package/lib/express/express-logging.js +1 -1
  148. package/lib/express/idempotency.js +1 -1
  149. package/lib/helpers/capabilities.js +84 -0
  150. package/lib/index.js +17 -13
  151. package/lib/jsonwp-proxy/protocol-converter.js +14 -13
  152. package/lib/jsonwp-proxy/proxy.js +16 -12
  153. package/lib/protocol/errors.js +42 -42
  154. package/lib/protocol/index.js +4 -4
  155. package/lib/protocol/protocol.js +35 -32
  156. package/lib/protocol/routes.js +69 -1
  157. package/package.json +37 -24
  158. package/test/basedriver/README.md +5 -0
  159. package/test/basedriver/driver-e2e-tests.js +1 -1
  160. package/test/basedriver/driver-tests.js +43 -9
  161. package/build/lib/protocol/sessions-cache.js +0 -88
  162. package/build/test/basedriver/capabilities-specs.js +0 -632
  163. package/build/test/basedriver/capability-specs.js +0 -396
  164. package/build/test/basedriver/commands/event-specs.js +0 -112
  165. package/build/test/basedriver/commands/log-specs.js +0 -80
  166. package/build/test/basedriver/driver-e2e-specs.js +0 -17
  167. package/build/test/basedriver/driver-specs.js +0 -17
  168. package/build/test/basedriver/helpers-e2e-specs.js +0 -194
  169. package/build/test/basedriver/helpers-specs.js +0 -153
  170. package/build/test/basedriver/timeout-specs.js +0 -139
  171. package/build/test/basedriver/websockets-e2e-specs.js +0 -84
  172. package/build/test/express/server-e2e-specs.js +0 -156
  173. package/build/test/express/server-specs.js +0 -151
  174. package/build/test/express/static-specs.js +0 -23
  175. package/build/test/jsonwp-proxy/mock-request.js +0 -93
  176. package/build/test/jsonwp-proxy/protocol-converter-specs.js +0 -173
  177. package/build/test/jsonwp-proxy/proxy-e2e-specs.js +0 -61
  178. package/build/test/jsonwp-proxy/proxy-specs.js +0 -294
  179. package/build/test/jsonwp-proxy/url-specs.js +0 -167
  180. package/build/test/jsonwp-status/status-specs.js +0 -36
  181. package/build/test/protocol/errors-specs.js +0 -388
  182. package/build/test/protocol/fake-driver.js +0 -168
  183. package/build/test/protocol/helpers.js +0 -27
  184. package/build/test/protocol/protocol-e2e-specs.js +0 -1182
  185. package/build/test/protocol/routes-specs.js +0 -82
  186. package/build/test/protocol/validator-specs.js +0 -151
  187. package/index.d.ts +0 -386
  188. package/lib/protocol/sessions-cache.js +0 -74
  189. package/test/basedriver/capabilities-specs.js +0 -505
  190. package/test/basedriver/capability-specs.js +0 -409
  191. package/test/basedriver/commands/event-specs.js +0 -74
  192. package/test/basedriver/commands/log-specs.js +0 -70
  193. package/test/basedriver/driver-e2e-specs.js +0 -8
  194. package/test/basedriver/driver-specs.js +0 -8
  195. package/test/basedriver/fixtures/BadZippedApp.zip +0 -1
  196. package/test/basedriver/fixtures/FakeAndroidApp.apk +0 -1
  197. package/test/basedriver/fixtures/FakeAndroidApp.asd +0 -0
  198. package/test/basedriver/fixtures/FakeIOSApp.app +0 -1
  199. package/test/basedriver/fixtures/FakeIOSApp.app.zip +0 -0
  200. package/test/basedriver/fixtures/FakeIOSApp.ipa +0 -0
  201. package/test/basedriver/fixtures/custom-element-finder-bad.js +0 -5
  202. package/test/basedriver/fixtures/custom-element-finder.js +0 -29
  203. package/test/basedriver/helpers-e2e-specs.js +0 -187
  204. package/test/basedriver/helpers-specs.js +0 -137
  205. package/test/basedriver/timeout-specs.js +0 -133
  206. package/test/basedriver/websockets-e2e-specs.js +0 -75
@@ -1,409 +0,0 @@
1
- import { default as BaseDriver, errors } from '../../lib';
2
- import logger from '../../lib/basedriver/logger';
3
- import sinon from 'sinon';
4
-
5
-
6
- describe('Desired Capabilities', function () {
7
- let d;
8
-
9
- beforeEach(function () {
10
- d = new BaseDriver();
11
- sinon.spy(logger, 'warn');
12
- });
13
-
14
- afterEach(function () {
15
- logger.warn.restore();
16
- });
17
-
18
- it('should require platformName and deviceName', async function () {
19
- try {
20
- await d.createSession(null, null, {});
21
- } catch (e) {
22
- e.should.be.instanceof(errors.SessionNotCreatedError);
23
- e.message.should.contain('platformName');
24
- return;
25
- }
26
-
27
- should.fail('error should have been thrown');
28
- });
29
-
30
-
31
- it('should require platformName', async function () {
32
- try {
33
- await d.createSession(null, null, {'deviceName': 'Delorean'});
34
- } catch (e) {
35
- e.should.be.instanceof(errors.SessionNotCreatedError);
36
- e.message.should.contain('platformName');
37
- return;
38
- }
39
-
40
- should.fail('error should have been thrown');
41
- });
42
-
43
- it('should not care about cap order', async function () {
44
-
45
- await d.createSession(null, null, {
46
- alwaysMatch: {
47
- 'appium:deviceName': 'Delorean',
48
- platformName: 'iOS'
49
- }
50
- });
51
-
52
- });
53
-
54
- it('should check required caps which are added to driver', async function () {
55
- d.desiredCapConstraints = {
56
- necessary: {
57
- presence: true
58
- },
59
- proper: {
60
- presence: true,
61
- isString: true,
62
- inclusion: ['Delorean', 'Reventon']
63
- }
64
- };
65
-
66
- try {
67
- await d.createSession(null, null, {
68
- alwaysMatch: {
69
- 'platformName': 'iOS',
70
- 'appium:deviceName': 'Delorean'
71
- }
72
- });
73
- } catch (e) {
74
- e.should.be.instanceof(errors.SessionNotCreatedError);
75
- e.message.should.contain('necessary');
76
- e.message.should.contain('proper');
77
- return;
78
- }
79
-
80
- should.fail('error should have been thrown');
81
- });
82
-
83
- it('should check added required caps in addition to base', async function () {
84
- d.desiredCapConstraints = {
85
- necessary: {
86
- presence: true
87
- },
88
- proper: {
89
- presence: true,
90
- isString: true,
91
- inclusion: ['Delorean', 'Reventon']
92
- }
93
- };
94
-
95
- try {
96
- await d.createSession(null, null, {
97
- alwaysMatch: {
98
- 'appium:necessary': 'yup'
99
- }
100
- });
101
- } catch (e) {
102
- e.should.be.instanceof(errors.SessionNotCreatedError);
103
- e.message.should.contain('platformName');
104
- return;
105
- }
106
-
107
- should.fail('error should have been thrown');
108
- });
109
-
110
- it('should accept extra capabilities', async function () {
111
- await d.createSession(null, null, {
112
- alwaysMatch: {
113
- 'platformName': 'iOS',
114
- 'appium:deviceName': 'Delorean',
115
- 'appium:extra': 'cheese',
116
- 'appium:hold the': 'sauce'
117
- }
118
- });
119
- });
120
-
121
- it('should log the use of extra caps', async function () {
122
- this.timeout(500);
123
-
124
- await d.createSession(null, null, {
125
- alwaysMatch: {
126
- 'platformName': 'iOS',
127
- 'appium:deviceName': 'Delorean',
128
- 'appium:extra': 'cheese',
129
- 'appium:hold the': 'sauce'
130
- }
131
- });
132
-
133
- logger.warn.callCount.should.be.above(0);
134
- });
135
-
136
- it('should be sensitive to the case of caps', async function () {
137
- try {
138
- await d.createSession(null, null, {
139
- alwaysMatch: {
140
- 'platformname': 'iOS',
141
- 'appium:deviceName': 'Delorean'
142
- }
143
- });
144
- } catch (e) {
145
- e.should.be.instanceof(errors.SessionNotCreatedError);
146
- e.message.should.contain('platformName');
147
- return;
148
- }
149
-
150
- should.fail('error should have been thrown');
151
- });
152
-
153
- describe('boolean capabilities', function () {
154
- it('should allow a string "false"', async function () {
155
- await d.createSession(null, null, {
156
- alwaysMatch: {
157
- 'platformName': 'iOS',
158
- 'appium:deviceName': 'Delorean',
159
- 'appium:noReset': 'false'
160
- }
161
- });
162
- logger.warn.callCount.should.be.above(0);
163
-
164
- let sessions = await d.getSessions();
165
- sessions[0].capabilities.noReset.should.eql(false);
166
- });
167
-
168
- it('should allow a string "true"', async function () {
169
- await d.createSession(null, null, {
170
- alwaysMatch: {
171
- 'platformName': 'iOS',
172
- 'appium:deviceName': 'Delorean',
173
- 'appium:noReset': 'true'
174
- }
175
- });
176
- logger.warn.callCount.should.be.above(0);
177
-
178
- let sessions = await d.getSessions();
179
- sessions[0].capabilities.noReset.should.eql(true);
180
- });
181
-
182
- it('should allow a string "true" in string capabilities', async function () {
183
- await d.createSession(null, null, {
184
- alwaysMatch: {
185
- 'platformName': 'iOS',
186
- 'appium:deviceName': 'Delorean',
187
- 'appium:language': 'true'
188
- }
189
- });
190
- logger.warn.callCount.should.equal(0);
191
-
192
- let sessions = await d.getSessions();
193
- sessions[0].capabilities.language.should.eql('true');
194
- });
195
- });
196
-
197
- describe('number capabilities', function () {
198
- it('should allow a string "1"', async function () {
199
- await d.createSession(null, null, {
200
- alwaysMatch: {
201
- 'platformName': 'iOS',
202
- 'appium:deviceName': 'Delorean',
203
- 'appium:newCommandTimeout': '1'
204
- }
205
- });
206
- logger.warn.callCount.should.be.above(0);
207
-
208
- let sessions = await d.getSessions();
209
- sessions[0].capabilities.newCommandTimeout.should.eql(1);
210
- });
211
-
212
- it('should allow a string "1.1"', async function () {
213
- await d.createSession(null, null, {
214
- alwaysMatch: {
215
- 'platformName': 'iOS',
216
- 'appium:deviceName': 'Delorean',
217
- 'appium:newCommandTimeout': '1.1'
218
- }
219
- });
220
- logger.warn.callCount.should.be.above(0);
221
-
222
- let sessions = await d.getSessions();
223
- sessions[0].capabilities.newCommandTimeout.should.eql(1.1);
224
- });
225
-
226
- it('should allow a string "1" in string capabilities', async function () {
227
- await d.createSession(null, null, {
228
- alwaysMatch: {
229
- 'platformName': 'iOS',
230
- 'appium:deviceName': 'Delorean',
231
- 'appium:language': '1'
232
- }
233
- });
234
- logger.warn.callCount.should.equal(0);
235
-
236
- let sessions = await d.getSessions();
237
- sessions[0].capabilities.language.should.eql('1');
238
- });
239
- });
240
-
241
- it ('should error if objects in caps', async function () {
242
- try {
243
- await d.createSession(null, null, {
244
- alwaysMatch: {
245
- 'platformName': {a: 'iOS'},
246
- 'appium:deviceName': 'Delorean'
247
- }
248
- });
249
- } catch (e) {
250
- e.should.be.instanceof(errors.SessionNotCreatedError);
251
- e.message.should.contain('platformName');
252
- return;
253
- }
254
-
255
- should.fail('error should have been thrown');
256
- });
257
-
258
- it('should check for deprecated caps', async function () {
259
- this.timeout(500);
260
-
261
- d.desiredCapConstraints = {
262
- 'lynx-version': {
263
- deprecated: true
264
- }
265
- };
266
-
267
- await d.createSession(null, null, {
268
- alwaysMatch: {
269
- 'platformName': 'iOS',
270
- 'appium:deviceName': 'Delorean',
271
- 'appium:lynx-version': 5
272
- }
273
- });
274
-
275
- logger.warn.callCount.should.be.above(0);
276
- });
277
-
278
- it('should not warn if deprecated=false', async function () {
279
- this.timeout(500);
280
-
281
- d.desiredCapConstraints = {
282
- 'lynx-version': {
283
- deprecated: false
284
- }
285
- };
286
-
287
- await d.createSession(null, null, {
288
- alwaysMatch: {
289
- 'platformName': 'iOS',
290
- 'appium:deviceName': 'Delorean',
291
- 'appium:lynx-version': 5
292
- }
293
- });
294
-
295
- logger.warn.callCount.should.equal(0);
296
- });
297
-
298
- it('should not validate against null/undefined caps', async function () {
299
- d.desiredCapConstraints = {
300
- 'foo': {
301
- isString: true
302
- }
303
- };
304
-
305
- await d.createSession(null, null, {
306
- alwaysMatch: {
307
- platformName: 'iOS',
308
- 'appium:deviceName': 'Dumb',
309
- 'appium:foo': null
310
- }
311
- });
312
- await d.deleteSession();
313
-
314
- await d.createSession(null, null, {
315
- alwaysMatch: {
316
- platformName: 'iOS',
317
- 'appium:deviceName': 'Dumb',
318
- 'appium:foo': 1
319
- }
320
- }).should.eventually.be.rejectedWith(/'foo' must be of type string/);
321
-
322
- await d.createSession(null, null, {
323
- alwaysMatch: {
324
- platformName: 'iOS',
325
- 'appium:deviceName': 'Dumb',
326
- 'appium:foo': undefined
327
- }
328
- });
329
- await d.deleteSession();
330
-
331
- await d.createSession(null, null, {
332
- alwaysMatch: {
333
- platformName: 'iOS',
334
- 'appium:deviceName': 'Dumb',
335
- 'appium:foo': ''
336
- }
337
- });
338
- await d.deleteSession();
339
- });
340
-
341
- it('should still validate null/undefined/empty caps whose presence is required', async function () {
342
- d.desiredCapConstraints = {
343
- foo: {
344
- presence: true
345
- },
346
- };
347
-
348
- await d.createSession(null, null, {
349
- alwaysMatch: {
350
- platformName: 'iOS',
351
- 'appium:deviceName': 'Dumb',
352
- 'appium:foo': null
353
- }
354
- }).should.eventually.be.rejectedWith(/blank/);
355
-
356
- await d.createSession(null, null, {
357
- platformName: 'iOS',
358
- 'appium:deviceName': 'Dumb',
359
- 'appium:foo': ''
360
- }).should.eventually.be.rejectedWith(/blank/);
361
-
362
- await d.createSession(null, null, {
363
- platformName: 'iOS',
364
- 'appium:deviceName': 'Dumb',
365
- 'appium:foo': {}
366
- }).should.eventually.be.rejectedWith(/blank/);
367
-
368
- await d.createSession(null, null, {
369
- platformName: 'iOS',
370
- 'appium:deviceName': 'Dumb',
371
- 'appium:foo': []
372
- }).should.eventually.be.rejectedWith(/blank/);
373
-
374
- await d.createSession(null, null, {
375
- platformName: 'iOS',
376
- 'appium:deviceName': 'Dumb',
377
- 'appium:foo': ' '
378
- }).should.eventually.be.rejectedWith(/blank/);
379
- });
380
-
381
- describe('w3c', function () {
382
- it('should accept w3c capabilities', async function () {
383
- const [sessionId, caps] = await d.createSession(null, null, {
384
- alwaysMatch: {
385
- platformName: 'iOS',
386
- 'appium:deviceName': 'Delorean'
387
- }, firstMatch: [{}],
388
- });
389
- sessionId.should.exist;
390
- caps.should.eql({
391
- platformName: 'iOS',
392
- deviceName: 'Delorean',
393
- });
394
- await d.deleteSession();
395
- });
396
-
397
- it('should raise an error if w3c capabilities is not a plain JSON object', async function () {
398
- for (const val of [true, 'string', [], 100]) {
399
- try {
400
- await d.createSession(null, null, val);
401
- } catch (e) {
402
- e.should.be.instanceof(errors.SessionNotCreatedError);
403
- continue;
404
- }
405
- should.fail('error should have been thrown');
406
- }
407
- });
408
- });
409
- });
@@ -1,74 +0,0 @@
1
- import _ from 'lodash';
2
- import { BaseDriver } from '../../../lib';
3
-
4
-
5
-
6
- describe('logging custom events', function () {
7
- it('should allow logging of events', async function () {
8
- const d = new BaseDriver();
9
- d._eventHistory.should.eql({commands: []});
10
- await d.logCustomEvent('myorg', 'myevent');
11
- _.keys(d._eventHistory).should.eql(['commands', 'myorg:myevent']);
12
- });
13
- it('should get all events including custom ones', async function () {
14
- const d = new BaseDriver();
15
- d._eventHistory.should.eql({commands: []});
16
- d.logEvent('appiumEvent');
17
- await d.logCustomEvent('myorg', 'myevent');
18
- const events = await d.getLogEvents();
19
- _.keys(events).should.eql(['commands', 'appiumEvent', 'myorg:myevent']);
20
- });
21
- });
22
-
23
- describe('#getLogEvents', function () {
24
- it('should allow to get all events', async function () {
25
- const d = new BaseDriver();
26
- d._eventHistory.should.eql({commands: []});
27
- d._eventHistory.testCommand = ['1', '2', '3'];
28
- await d.getLogEvents().should.eql({
29
- commands: [], testCommand: ['1', '2', '3']
30
- });
31
- });
32
-
33
- it('should filter with testCommand', async function () {
34
- const d = new BaseDriver();
35
- d._eventHistory.should.eql({commands: []});
36
- d._eventHistory.testCommand = ['1', '2', '3'];
37
- await d.getLogEvents('testCommand').should.eql({
38
- testCommand: ['1', '2', '3']
39
- });
40
- });
41
-
42
- it('should not filter with wrong but can be a part of the event name', async function () {
43
- const d = new BaseDriver();
44
- d._eventHistory.should.eql({commands: []});
45
- d._eventHistory.testCommand = ['1', '2', '3'];
46
- await d.getLogEvents('testCommandDummy').should.eql({});
47
- });
48
-
49
- it('should filter with multiple event keys', async function () {
50
- const d = new BaseDriver();
51
- d._eventHistory.should.eql({commands: []});
52
- d._eventHistory.testCommand = ['1', '2', '3'];
53
- d._eventHistory.testCommand2 = ['4', '5'];
54
- await d.getLogEvents(['testCommand', 'testCommand2']).should.eql({
55
- testCommand: ['1', '2', '3'], testCommand2: ['4', '5']
56
- });
57
- });
58
-
59
- it('should filter with custom events', async function () {
60
- const d = new BaseDriver();
61
- d._eventHistory.should.eql({commands: []});
62
- d._eventHistory['custom:appiumEvent'] = ['1', '2', '3'];
63
- await d.getLogEvents(['custom:appiumEvent']).should.eql({
64
- 'custom:appiumEvent': ['1', '2', '3']
65
- });
66
- });
67
-
68
- it('should not filter with no existed event name', async function () {
69
- const d = new BaseDriver();
70
- d._eventHistory.should.eql({commands: []});
71
- d._eventHistory.testCommand = ['1', '2', '3'];
72
- await d.getLogEvents(['noEventName']).should.eql({});
73
- });
74
- });
@@ -1,70 +0,0 @@
1
- import logCommands from '../../../lib/basedriver/commands/log';
2
- import sinon from 'sinon';
3
- import _ from 'lodash';
4
-
5
-
6
- const expect = chai.expect;
7
-
8
- const FIRST_LOGS = ['first', 'logs'];
9
- const SECOND_LOGS = ['second', 'logs'];
10
- const SUPPORTED_LOG_TYPES = {
11
- one: {
12
- description: 'First logs',
13
- getter: () => _.clone(FIRST_LOGS),
14
- },
15
- two: {
16
- description: 'Seconds logs',
17
- getter: () => _.clone(SECOND_LOGS),
18
- },
19
- };
20
-
21
- describe('log commands -', function () {
22
- beforeEach(function () {
23
- // reset the supported log types
24
- logCommands.supportedLogTypes = {};
25
- });
26
- describe('getLogTypes', function () {
27
- it('should return empty array when no supported log types', async function () {
28
- (await logCommands.getLogTypes()).should.eql([]);
29
- });
30
- it('should return keys to log type object', async function () {
31
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
32
- (await logCommands.getLogTypes()).should.eql(['one', 'two']);
33
- });
34
- });
35
- describe('getLog', function () {
36
- beforeEach(function () {
37
- sinon.spy(SUPPORTED_LOG_TYPES.one, 'getter');
38
- sinon.spy(SUPPORTED_LOG_TYPES.two, 'getter');
39
- });
40
- afterEach(function () {
41
- SUPPORTED_LOG_TYPES.one.getter.restore();
42
- SUPPORTED_LOG_TYPES.two.getter.restore();
43
- });
44
- it('should throw error if log type not supported', async function () {
45
- await logCommands.getLog('one').should.eventually.be.rejected;
46
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.false;
47
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
48
- });
49
- it('should throw an error with available log types if log type not supported', async function () {
50
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
51
- let err;
52
- try {
53
- await logCommands.getLog('three');
54
- } catch (_err) {
55
- err = _err;
56
- }
57
- expect(err).to.exist;
58
- err.message.should.eql(`Unsupported log type 'three'. Supported types: {"one":"First logs","two":"Seconds logs"}`);
59
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.false;
60
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
61
- });
62
- it('should call getter on appropriate log when found', async function () {
63
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
64
- let logs = await logCommands.getLog('one');
65
- logs.should.eql(FIRST_LOGS);
66
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.true;
67
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
68
- });
69
- });
70
- });
@@ -1,8 +0,0 @@
1
- // transpile:mocha
2
-
3
- import BaseDriver from '../../lib';
4
- import baseDriverE2ETests from './driver-e2e-tests';
5
- baseDriverE2ETests(BaseDriver, {
6
- platformName: 'iOS',
7
- 'appium:deviceName': 'Delorean'
8
- });
@@ -1,8 +0,0 @@
1
- // transpile:mocha
2
-
3
- import BaseDriver from '../../lib';
4
- import baseDriverUnitTests from './driver-tests';
5
- baseDriverUnitTests(BaseDriver, {
6
- platformName: 'iOS',
7
- 'appium:deviceName': 'Delorean'
8
- });
@@ -1 +0,0 @@
1
- zip zip zip
@@ -1 +0,0 @@
1
- this is not really an apk
@@ -1 +0,0 @@
1
- this is not really an app
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- notFind: function () { // eslint-disable-line object-shorthand
3
- return [];
4
- }
5
- };
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- find: function (driver, logger, selector, multiple) { // eslint-disable-line object-shorthand
3
- if (!driver || !driver.opts) {
4
- throw new Error('Expected driver object');
5
- }
6
-
7
- if (!logger || !logger.info) {
8
- throw new Error('Expected logger object');
9
- }
10
-
11
- if (selector === 'foo') {
12
- return ['bar'];
13
- }
14
-
15
- if (selector === 'foos') {
16
- if (multiple) {
17
- return ['baz1', 'baz2'];
18
- }
19
-
20
- return ['bar1', 'bar2'];
21
- }
22
-
23
- if (selector === 'error') {
24
- throw new Error('This is a plugin error');
25
- }
26
-
27
- return [];
28
- }
29
- };