@appium/base-driver 8.2.3 → 8.3.1

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 (128) hide show
  1. package/build/lib/basedriver/capabilities.js +2 -4
  2. package/build/lib/basedriver/commands/event.js +2 -4
  3. package/build/lib/basedriver/commands/find.js +5 -14
  4. package/build/lib/basedriver/commands/index.js +2 -4
  5. package/build/lib/basedriver/commands/log.js +4 -9
  6. package/build/lib/basedriver/commands/session.js +19 -30
  7. package/build/lib/basedriver/commands/settings.js +5 -11
  8. package/build/lib/basedriver/commands/timeout.js +11 -18
  9. package/build/lib/basedriver/desired-caps.js +2 -4
  10. package/build/lib/basedriver/device-settings.js +15 -5
  11. package/build/lib/basedriver/driver.js +36 -23
  12. package/build/lib/basedriver/helpers.js +10 -12
  13. package/build/lib/basedriver/logger.js +2 -4
  14. package/build/lib/constants.js +2 -4
  15. package/build/lib/express/crash.js +2 -4
  16. package/build/lib/express/express-logging.js +3 -5
  17. package/build/lib/express/idempotency.js +3 -5
  18. package/build/lib/express/logger.js +2 -4
  19. package/build/lib/express/middleware.js +2 -4
  20. package/build/lib/express/server.js +2 -4
  21. package/build/lib/express/static.js +2 -4
  22. package/build/lib/express/websocket.js +2 -4
  23. package/build/lib/helpers/capabilities.js +37 -0
  24. package/build/lib/index.js +4 -8
  25. package/build/lib/jsonwp-proxy/protocol-converter.js +19 -15
  26. package/build/lib/jsonwp-proxy/proxy.js +20 -15
  27. package/build/lib/jsonwp-status/status.js +2 -4
  28. package/build/lib/protocol/errors.js +2 -4
  29. package/build/lib/protocol/helpers.js +2 -4
  30. package/build/lib/protocol/index.js +2 -4
  31. package/build/lib/protocol/protocol.js +37 -30
  32. package/build/lib/protocol/routes.js +68 -4
  33. package/build/lib/protocol/validators.js +2 -4
  34. package/build/test/basedriver/README.md +5 -0
  35. package/build/test/basedriver/driver-e2e-tests.js +2 -4
  36. package/build/test/basedriver/driver-tests.js +12 -17
  37. package/build/test/basedriver/index.js +2 -4
  38. package/build/test/e2e/basedriver/driver.e2e.spec.js +15 -0
  39. package/build/test/e2e/basedriver/helpers.e2e.spec.js +192 -0
  40. package/build/test/e2e/basedriver/websockets.e2e.spec.js +82 -0
  41. package/build/test/e2e/express/server.e2e.spec.js +159 -0
  42. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +59 -0
  43. package/build/test/e2e/protocol/fake-driver.js +163 -0
  44. package/build/test/e2e/protocol/helpers.js +25 -0
  45. package/build/test/e2e/protocol/protocol.e2e.spec.js +1186 -0
  46. package/build/test/helpers.js +2 -4
  47. package/build/test/unit/basedriver/capabilities.spec.js +672 -0
  48. package/build/test/unit/basedriver/capability.spec.js +353 -0
  49. package/build/test/unit/basedriver/commands/event.spec.js +110 -0
  50. package/build/test/unit/basedriver/commands/log.spec.js +85 -0
  51. package/build/test/unit/basedriver/driver.spec.js +15 -0
  52. package/build/test/unit/basedriver/helpers.spec.js +151 -0
  53. package/build/test/unit/basedriver/timeout.spec.js +135 -0
  54. package/build/test/unit/express/server.spec.js +155 -0
  55. package/build/test/unit/express/static.spec.js +26 -0
  56. package/build/test/unit/jsonwp-proxy/mock-request.js +91 -0
  57. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +171 -0
  58. package/build/test/unit/jsonwp-proxy/proxy.spec.js +292 -0
  59. package/build/test/unit/jsonwp-proxy/url.spec.js +165 -0
  60. package/build/test/unit/jsonwp-status/status.spec.js +34 -0
  61. package/build/test/unit/protocol/errors.spec.js +390 -0
  62. package/build/test/unit/protocol/routes.spec.js +80 -0
  63. package/build/test/unit/protocol/validator.spec.js +149 -0
  64. package/lib/basedriver/commands/find.js +3 -6
  65. package/lib/basedriver/commands/log.js +2 -4
  66. package/lib/basedriver/commands/session.js +21 -22
  67. package/lib/basedriver/commands/settings.js +3 -5
  68. package/lib/basedriver/commands/timeout.js +9 -10
  69. package/lib/basedriver/device-settings.js +10 -1
  70. package/lib/basedriver/driver.js +36 -12
  71. package/lib/basedriver/helpers.js +13 -11
  72. package/lib/express/express-logging.js +1 -1
  73. package/lib/express/idempotency.js +1 -1
  74. package/lib/helpers/capabilities.js +25 -0
  75. package/lib/index.js +2 -2
  76. package/lib/jsonwp-proxy/protocol-converter.js +14 -13
  77. package/lib/jsonwp-proxy/proxy.js +16 -12
  78. package/lib/protocol/protocol.js +34 -29
  79. package/lib/protocol/routes.js +60 -1
  80. package/package.json +36 -24
  81. package/test/basedriver/README.md +5 -0
  82. package/test/basedriver/driver-e2e-tests.js +1 -1
  83. package/test/basedriver/driver-tests.js +12 -7
  84. package/build/lib/protocol/sessions-cache.js +0 -88
  85. package/build/test/basedriver/capabilities-specs.js +0 -632
  86. package/build/test/basedriver/capability-specs.js +0 -396
  87. package/build/test/basedriver/commands/event-specs.js +0 -112
  88. package/build/test/basedriver/commands/log-specs.js +0 -80
  89. package/build/test/basedriver/driver-e2e-specs.js +0 -17
  90. package/build/test/basedriver/driver-specs.js +0 -17
  91. package/build/test/basedriver/helpers-e2e-specs.js +0 -194
  92. package/build/test/basedriver/helpers-specs.js +0 -153
  93. package/build/test/basedriver/timeout-specs.js +0 -139
  94. package/build/test/basedriver/websockets-e2e-specs.js +0 -84
  95. package/build/test/express/server-e2e-specs.js +0 -156
  96. package/build/test/express/server-specs.js +0 -151
  97. package/build/test/express/static-specs.js +0 -23
  98. package/build/test/jsonwp-proxy/mock-request.js +0 -93
  99. package/build/test/jsonwp-proxy/protocol-converter-specs.js +0 -173
  100. package/build/test/jsonwp-proxy/proxy-e2e-specs.js +0 -61
  101. package/build/test/jsonwp-proxy/proxy-specs.js +0 -294
  102. package/build/test/jsonwp-proxy/url-specs.js +0 -167
  103. package/build/test/jsonwp-status/status-specs.js +0 -36
  104. package/build/test/protocol/errors-specs.js +0 -388
  105. package/build/test/protocol/fake-driver.js +0 -168
  106. package/build/test/protocol/helpers.js +0 -27
  107. package/build/test/protocol/protocol-e2e-specs.js +0 -1182
  108. package/build/test/protocol/routes-specs.js +0 -82
  109. package/build/test/protocol/validator-specs.js +0 -151
  110. package/lib/protocol/sessions-cache.js +0 -74
  111. package/test/basedriver/capabilities-specs.js +0 -505
  112. package/test/basedriver/capability-specs.js +0 -409
  113. package/test/basedriver/commands/event-specs.js +0 -74
  114. package/test/basedriver/commands/log-specs.js +0 -70
  115. package/test/basedriver/driver-e2e-specs.js +0 -8
  116. package/test/basedriver/driver-specs.js +0 -8
  117. package/test/basedriver/fixtures/BadZippedApp.zip +0 -1
  118. package/test/basedriver/fixtures/FakeAndroidApp.apk +0 -1
  119. package/test/basedriver/fixtures/FakeAndroidApp.asd +0 -0
  120. package/test/basedriver/fixtures/FakeIOSApp.app +0 -1
  121. package/test/basedriver/fixtures/FakeIOSApp.app.zip +0 -0
  122. package/test/basedriver/fixtures/FakeIOSApp.ipa +0 -0
  123. package/test/basedriver/fixtures/custom-element-finder-bad.js +0 -5
  124. package/test/basedriver/fixtures/custom-element-finder.js +0 -29
  125. package/test/basedriver/helpers-e2e-specs.js +0 -187
  126. package/test/basedriver/helpers-specs.js +0 -137
  127. package/test/basedriver/timeout-specs.js +0 -133
  128. 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
- };