@appium/driver-test-support 1.0.6 → 1.1.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.
@@ -1,45 +1,40 @@
1
1
  import _ from 'lodash';
2
- import B from 'bluebird';
2
+ import {sleep} from 'asyncbox';
3
3
  import {createSandbox} from 'sinon';
4
-
5
- // wrap these tests in a function so we can export the tests and re-use them
6
- // for actual driver implementations
4
+ import type {
5
+ Constraints,
6
+ Driver,
7
+ DriverClass,
8
+ NSDriverCaps,
9
+ W3CDriverCaps,
10
+ } from '@appium/types';
7
11
 
8
12
  /**
9
13
  * Creates unit test suites for a driver.
10
- * @template {Constraints} C
11
- * @param {DriverClass<C>} DriverClass
12
- * @param {import('@appium/types').NSDriverCaps<C>} [defaultCaps]
13
14
  */
14
-
15
- export function driverUnitTestSuite(
16
- DriverClass,
17
- defaultCaps = /** @type {import('@appium/types').NSDriverCaps<C>} */ ({})
18
- ) {
19
- // to display the driver under test in report
15
+ export function driverUnitTestSuite<C extends Constraints>(
16
+ DriverClass: DriverClass<Driver<C>>,
17
+ defaultCaps: NSDriverCaps<C> = {} as NSDriverCaps<C>
18
+ ): void {
20
19
  const className = DriverClass.name ?? '(unknown driver)';
21
20
 
22
21
  describe(`BaseDriver unit suite (as ${className})`, function () {
23
- /** @type {InstanceType<typeof DriverClass>} */
24
- let d;
25
- /** @type {import('@appium/types').W3CDriverCaps<C>} */
26
- let w3cCaps;
27
- /** @type {import('sinon').SinonSandbox} */
28
- let sandbox;
29
- let expect;
30
- let should;
22
+ let d: InstanceType<typeof DriverClass>;
23
+ let w3cCaps: W3CDriverCaps<C>;
24
+ let sandbox: ReturnType<typeof createSandbox>;
25
+ let expect: Chai.ExpectStatic;
31
26
 
32
27
  before(async function () {
33
28
  const chai = await import('chai');
34
29
  const chaiAsPromised = await import('chai-as-promised');
35
- chai.use(chaiAsPromised.default);
36
- expect = chai.expect;
37
- should = chai.should();
30
+ (chai as any).use((chaiAsPromised as any).default);
31
+ expect = (chai as any).expect;
32
+ (chai as any).should(); // for client code that may use should style
38
33
  });
39
34
 
40
35
  beforeEach(function () {
41
36
  sandbox = createSandbox();
42
- d = new DriverClass();
37
+ d = new DriverClass() as InstanceType<typeof DriverClass>;
43
38
  w3cCaps = {
44
39
  alwaysMatch: {
45
40
  ...defaultCaps,
@@ -63,13 +58,13 @@ export function driverUnitTestSuite(
63
58
  });
64
59
 
65
60
  it('should return an empty status object', async function () {
66
- let status = await d.getStatus();
67
- status.should.eql({});
61
+ const status = await d.getStatus();
62
+ expect(status).to.eql({});
68
63
  });
69
64
 
70
65
  it('should return a sessionId from createSession', async function () {
71
- let [sessId] = await d.createSession(w3cCaps);
72
- should.exist(sessId);
66
+ const [sessId] = await d.createSession(w3cCaps);
67
+ expect(sessId).to.exist;
73
68
  expect(sessId).to.be.a('string');
74
69
  expect(sessId.length).to.be.above(5);
75
70
  });
@@ -80,27 +75,26 @@ export function driverUnitTestSuite(
80
75
  });
81
76
 
82
77
  it('should be able to delete a session', async function () {
83
- let sessionId1 = await d.createSession(_.cloneDeep(w3cCaps));
78
+ const sessionId1 = await d.createSession(_.cloneDeep(w3cCaps));
84
79
  await d.deleteSession();
85
- should.equal(d.sessionId, null);
86
- let sessionId2 = await d.createSession(_.cloneDeep(w3cCaps));
80
+ expect(d.sessionId).to.equal(null);
81
+ const sessionId2 = await d.createSession(_.cloneDeep(w3cCaps));
87
82
  expect(sessionId1).to.not.eql(sessionId2);
88
83
  });
89
84
 
90
85
  it('should get the current session', async function () {
91
- let [, caps] = await d.createSession(w3cCaps);
86
+ const [, caps] = await d.createSession(w3cCaps);
92
87
  expect(caps).to.equal(await d.getSession());
93
88
  });
94
89
 
95
90
  it('should fulfill an unexpected driver quit promise', async function () {
96
- // make a command that will wait a bit so we can crash while it's running
97
91
  sandbox.stub(d, 'getStatus').callsFake(async () => {
98
- await B.delay(1000);
92
+ await sleep(1000);
99
93
  return 'good status';
100
94
  });
101
- let cmdPromise = d.executeCommand('getStatus');
102
- await B.delay(10);
103
- const p = new B((resolve, reject) => {
95
+ const cmdPromise = d.executeCommand('getStatus');
96
+ await sleep(10);
97
+ const p = new Promise<void>((resolve, reject) => {
104
98
  setTimeout(
105
99
  () =>
106
100
  reject(
@@ -118,13 +112,12 @@ export function driverUnitTestSuite(
118
112
  });
119
113
 
120
114
  it('should not allow commands in middle of unexpected shutdown', async function () {
121
- // make a command that will wait a bit so we can crash while it's running
122
- sandbox.stub(d, 'deleteSession').callsFake(async function () {
123
- await B.delay(100);
115
+ sandbox.stub(d, 'deleteSession').callsFake(async function (this: InstanceType<typeof DriverClass>) {
116
+ await sleep(100);
124
117
  DriverClass.prototype.deleteSession.call(this);
125
118
  });
126
119
  await d.createSession(w3cCaps);
127
- const p = new B((resolve, reject) => {
120
+ const p = new Promise<void>((resolve, reject) => {
128
121
  setTimeout(
129
122
  () =>
130
123
  reject(
@@ -142,14 +135,13 @@ export function driverUnitTestSuite(
142
135
  });
143
136
 
144
137
  it('should allow new commands after done shutting down', async function () {
145
- // make a command that will wait a bit so we can crash while it's running
146
- sandbox.stub(d, 'deleteSession').callsFake(async function () {
147
- await B.delay(100);
138
+ sandbox.stub(d, 'deleteSession').callsFake(async function (this: InstanceType<typeof DriverClass>) {
139
+ await sleep(100);
148
140
  DriverClass.prototype.deleteSession.call(this);
149
141
  });
150
142
 
151
143
  await d.createSession(_.cloneDeep(w3cCaps));
152
- const p = new B((resolve, reject) => {
144
+ const p = new Promise<void>((resolve, reject) => {
153
145
  setTimeout(
154
146
  () =>
155
147
  reject(
@@ -165,14 +157,13 @@ export function driverUnitTestSuite(
165
157
  await p;
166
158
 
167
159
  await expect(d.executeCommand('getSession')).to.be.rejectedWith(/shut down/);
168
- await B.delay(500);
160
+ await sleep(500);
169
161
 
170
162
  await d.executeCommand('createSession', null, null, _.cloneDeep(w3cCaps));
171
163
  await d.deleteSession();
172
164
  });
173
165
 
174
166
  it('should distinguish between W3C and JSONWP session', async function () {
175
- // Test W3C (leave first 2 args null because those are the JSONWP args)
176
167
  await d.executeCommand('createSession', null, null, {
177
168
  alwaysMatch: {
178
169
  ...defaultCaps,
@@ -188,7 +179,7 @@ export function driverUnitTestSuite(
188
179
  describe('protocol detection', function () {
189
180
  it('should use W3C if only W3C caps are provided', async function () {
190
181
  await d.createSession({
191
- alwaysMatch: _.clone(defaultCaps),
182
+ alwaysMatch: _.clone(defaultCaps) as object,
192
183
  firstMatch: [{}],
193
184
  });
194
185
  expect(d.protocol).to.equal('W3C');
@@ -196,23 +187,22 @@ export function driverUnitTestSuite(
196
187
  });
197
188
 
198
189
  it('should have a method to get driver for a session', async function () {
199
- let [sessId] = await d.createSession(w3cCaps);
190
+ const [sessId] = await d.createSession(w3cCaps);
200
191
  expect(d.driverForSession(sessId)).to.eql(d);
201
192
  });
202
193
 
203
194
  describe('command queue', function () {
204
- /** @type {InstanceType<DriverClass<Constraints>>} */
205
- let d;
206
- let waitMs = 10;
195
+ let d: InstanceType<typeof DriverClass>;
196
+ const waitMs = 10;
207
197
 
208
198
  beforeEach(function () {
209
- d = new DriverClass();
199
+ d = new DriverClass() as InstanceType<typeof DriverClass>;
210
200
  sandbox.stub(d, 'getStatus').callsFake(async () => {
211
- await B.delay(waitMs);
201
+ await sleep(waitMs);
212
202
  return Date.now();
213
203
  });
214
204
  sandbox.stub(d, 'deleteSession').callsFake(async () => {
215
- await B.delay(waitMs);
205
+ await sleep(waitMs);
216
206
  throw new Error('multipass');
217
207
  });
218
208
  });
@@ -222,12 +212,12 @@ export function driverUnitTestSuite(
222
212
  });
223
213
 
224
214
  it('should queue commands and.executeCommand/respond in the order received', async function () {
225
- let numCmds = 10;
226
- let cmds = [];
215
+ const numCmds = 10;
216
+ const cmds: Promise<number>[] = [];
227
217
  for (let i = 0; i < numCmds; i++) {
228
218
  cmds.push(d.executeCommand('getStatus'));
229
219
  }
230
- let results = await B.all(cmds);
220
+ const results = await Promise.all(cmds) as number[];
231
221
  for (let i = 1; i < numCmds; i++) {
232
222
  if (results[i] <= results[i - 1]) {
233
223
  throw new Error('Got result out of order');
@@ -236,8 +226,8 @@ export function driverUnitTestSuite(
236
226
  });
237
227
 
238
228
  it('should handle errors correctly when queuing', async function () {
239
- let numCmds = 10;
240
- let cmds = [];
229
+ const numCmds = 10;
230
+ const cmds: Promise<number | void>[] = [];
241
231
  for (let i = 0; i < numCmds; i++) {
242
232
  if (i === 5) {
243
233
  cmds.push(d.executeCommand('deleteSession'));
@@ -245,37 +235,41 @@ export function driverUnitTestSuite(
245
235
  cmds.push(d.executeCommand('getStatus'));
246
236
  }
247
237
  }
248
- let results = /** @type {PromiseFulfilledResult<any>[]} */ (
249
-
250
- await Promise.allSettled(cmds)
251
- );
238
+ const results = await Promise.allSettled(cmds);
252
239
  for (let i = 1; i < 5; i++) {
253
- if (results[i].value <= results[i - 1].value) {
254
- throw new Error('Got result out of order');
240
+ const r = results[i];
241
+ const rPrev = results[i - 1];
242
+ if (r.status === 'fulfilled' && rPrev.status === 'fulfilled') {
243
+ if (r.value <= rPrev.value) {
244
+ throw new Error('Got result out of order');
245
+ }
255
246
  }
256
247
  }
257
- /** @type {PromiseRejectedResult} */ (
258
- /** @type {unknown} */ (results[5])
259
- ).reason.message.should.contain('multipass');
248
+ const rejected = results[5] as PromiseRejectedResult;
249
+ expect(rejected.reason.message).to.contain('multipass');
260
250
  for (let i = 7; i < numCmds; i++) {
261
- if (results[i].value <= results[i - 1].value) {
262
- throw new Error('Got result out of order');
251
+ const r = results[i];
252
+ const rPrev = results[i - 1];
253
+ if (r.status === 'fulfilled' && rPrev.status === 'fulfilled') {
254
+ if (r.value <= rPrev.value) {
255
+ throw new Error('Got result out of order');
256
+ }
263
257
  }
264
258
  }
265
259
  });
266
260
 
267
261
  it('should not care if queue empties for a bit', async function () {
268
- let numCmds = 10;
269
- let cmds = [];
262
+ const numCmds = 10;
263
+ let cmds: Promise<number>[] = [];
270
264
  for (let i = 0; i < numCmds; i++) {
271
265
  cmds.push(d.executeCommand('getStatus'));
272
266
  }
273
- let results = await B.all(cmds);
267
+ let results = await Promise.all(cmds) as number[];
274
268
  cmds = [];
275
269
  for (let i = 0; i < numCmds; i++) {
276
270
  cmds.push(d.executeCommand('getStatus'));
277
271
  }
278
- results = await B.all(cmds);
272
+ results = await Promise.all(cmds) as number[];
279
273
  for (let i = 1; i < numCmds; i++) {
280
274
  if (results[i] <= results[i - 1]) {
281
275
  throw new Error('Got result out of order');
@@ -348,7 +342,7 @@ export function driverUnitTestSuite(
348
342
  });
349
343
 
350
344
  describe('proxying', function () {
351
- let sessId;
345
+ let sessId: string;
352
346
  beforeEach(async function () {
353
347
  [sessId] = await d.createSession(w3cCaps);
354
348
  });
@@ -389,7 +383,7 @@ export function driverUnitTestSuite(
389
383
  });
390
384
  it('should throw an error when sessionId is wrong', function () {
391
385
  expect(() => {
392
- d.canProxy();
386
+ d.canProxy(undefined as any);
393
387
  }).to.throw;
394
388
  });
395
389
  });
@@ -397,44 +391,36 @@ export function driverUnitTestSuite(
397
391
  describe('#proxyRouteIsAvoided', function () {
398
392
  it('should validate form of avoidance list', function () {
399
393
  const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
400
- // @ts-expect-error
401
- avoidStub.returns([['POST', /\/foo/], ['GET']]);
394
+ avoidStub.returns([['POST', /\/foo/], ['GET']] as any);
402
395
  expect(() => {
403
- // @ts-expect-error
404
- d.proxyRouteIsAvoided();
396
+ (d as any).proxyRouteIsAvoided();
405
397
  }).to.throw;
406
398
  avoidStub.returns([
407
399
  ['POST', /\/foo/],
408
- // @ts-expect-error
409
400
  ['GET', /^foo/, 'bar'],
410
- ]);
401
+ ] as any);
411
402
  expect(() => {
412
- // @ts-expect-error
413
- d.proxyRouteIsAvoided();
403
+ (d as any).proxyRouteIsAvoided();
414
404
  }).to.throw;
415
405
  });
416
406
  it('should reject bad http methods', function () {
417
407
  const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
418
408
  avoidStub.returns([
419
409
  ['POST', /^foo/],
420
- // @ts-expect-error
421
- ['BAZETE', /^bar/],
410
+ ['BAZETE' as any, /^bar/],
422
411
  ]);
423
412
  expect(() => {
424
- // @ts-expect-error
425
- d.proxyRouteIsAvoided();
413
+ (d as any).proxyRouteIsAvoided();
426
414
  }).to.throw;
427
415
  });
428
416
  it('should reject non-regex routes', function () {
429
417
  const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
430
418
  avoidStub.returns([
431
419
  ['POST', /^foo/],
432
- // @ts-expect-error
433
- ['GET', '/bar'],
420
+ ['GET', '/bar' as any],
434
421
  ]);
435
422
  expect(() => {
436
- // @ts-expect-error
437
- d.proxyRouteIsAvoided();
423
+ (d as any).proxyRouteIsAvoided();
438
424
  }).to.throw;
439
425
  });
440
426
  it('should return true for routes in the avoid list', function () {
@@ -457,7 +443,7 @@ export function driverUnitTestSuite(
457
443
  });
458
444
 
459
445
  describe('event timing framework', function () {
460
- let beforeStartTime;
446
+ let beforeStartTime: number;
461
447
  beforeEach(async function () {
462
448
  beforeStartTime = Date.now();
463
449
  d.shouldValidateCaps = false;
@@ -468,16 +454,16 @@ export function driverUnitTestSuite(
468
454
  });
469
455
  describe('#eventHistory', function () {
470
456
  it('should have an eventHistory property', function () {
471
- should.exist(d.eventHistory);
472
- should.exist(d.eventHistory.commands);
457
+ expect(d.eventHistory).to.exist;
458
+ expect(d.eventHistory.commands).to.exist;
473
459
  });
474
460
 
475
461
  it('should have a session start timing after session start', function () {
476
- let {newSessionRequested, newSessionStarted} = d.eventHistory;
477
- newSessionRequested.should.have.length(1);
478
- newSessionStarted.should.have.length(1);
479
- newSessionRequested[0].should.be.a('number');
480
- newSessionStarted[0].should.be.a('number');
462
+ const {newSessionRequested, newSessionStarted} = d.eventHistory;
463
+ expect(newSessionRequested).to.have.length(1);
464
+ expect(newSessionStarted).to.have.length(1);
465
+ expect(newSessionRequested[0]).to.be.a('number');
466
+ expect(newSessionStarted[0]).to.be.a('number');
481
467
  expect(newSessionRequested[0] >= beforeStartTime).to.be.true;
482
468
  expect(newSessionStarted[0] >= newSessionRequested[0]).to.be.true;
483
469
  });
@@ -501,12 +487,10 @@ export function driverUnitTestSuite(
501
487
  d.logEvent('commands');
502
488
  }).to.throw();
503
489
  expect(() => {
504
- // @ts-expect-error - bad type
505
- d.logEvent(1);
490
+ d.logEvent(1 as any);
506
491
  }).to.throw();
507
492
  expect(() => {
508
- // @ts-expect-error - bad type
509
- d.logEvent({});
493
+ d.logEvent({} as any);
510
494
  }).to.throw();
511
495
  });
512
496
  });
@@ -520,12 +504,12 @@ export function driverUnitTestSuite(
520
504
  describe('getSession decoration', function () {
521
505
  it('should decorate getSession response if opt-in cap is provided', async function () {
522
506
  let res = await d.getSession();
523
- should.not.exist(res.events);
507
+ expect(res.events).to.not.exist;
524
508
 
525
509
  _.set(d, 'caps.eventTimings', true);
526
510
  res = await d.getSession();
527
- should.exist(res.events);
528
- should.exist(res.events?.newSessionRequested);
511
+ expect(res.events).to.exist;
512
+ expect(res.events?.newSessionRequested).to.exist;
529
513
  expect(res.events?.newSessionRequested[0]).to.be.a('number');
530
514
  });
531
515
  });
@@ -533,16 +517,17 @@ export function driverUnitTestSuite(
533
517
  });
534
518
 
535
519
  describe('.isFeatureEnabled', function () {
536
- let d;
537
- let expect;
520
+ let d: InstanceType<typeof DriverClass>;
521
+ let expect: Chai.ExpectStatic;
538
522
 
539
523
  before(async function () {
540
524
  const chai = await import('chai');
541
- expect = chai.expect;
525
+ expect = (chai as any).expect;
526
+ (chai as any).should(); // for client code that may use should style
542
527
  });
543
528
 
544
529
  beforeEach(function () {
545
- d = new DriverClass();
530
+ d = new DriverClass() as InstanceType<typeof DriverClass>;
546
531
  });
547
532
 
548
533
  it('should throw if feature name is invalid', function () {
@@ -593,23 +578,3 @@ export function driverUnitTestSuite(
593
578
  });
594
579
  });
595
580
  }
596
-
597
- /**
598
- * @typedef {import('@appium/types').BaseNSCapabilities} BaseNSCapabilities
599
- * @typedef {import('@appium/types').Constraints} Constraints
600
- */
601
-
602
- /**
603
- * @template {Constraints} C
604
- * @typedef {import('@appium/types').DriverClass<Driver<C>>} DriverClass
605
- */
606
-
607
- /**
608
- * @template {Constraints} C
609
- * @typedef {import('@appium/types').Driver<C>} Driver
610
- */
611
-
612
- /**
613
- * @template {Constraints} C
614
- * @typedef {import('@appium/types').W3CCapabilities<C>} W3CCapabilities
615
- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/driver-test-support",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "Test utilities for Appium drivers",
5
5
  "keywords": [
6
6
  "automation",
@@ -23,34 +23,33 @@
23
23
  },
24
24
  "license": "Apache-2.0",
25
25
  "author": "https://github.com/appium",
26
- "main": "index.js",
26
+ "main": "./build/lib/index.js",
27
27
  "directories": {
28
- "lib": "lib"
28
+ "lib": "./lib"
29
29
  },
30
30
  "files": [
31
- "index.js",
31
+ "build/lib",
32
32
  "lib",
33
- "build",
34
- "tsconfig.json",
35
- "!build/tsconfig.tsbuildinfo",
36
- "!build/test"
33
+ "tsconfig.json"
37
34
  ],
38
35
  "scripts": {
39
36
  "test": "npm run test:unit",
40
- "test:smoke": "node ./index.js",
41
- "test:unit": "mocha \"test/unit/**/*.spec.js\""
37
+ "test:smoke": "node ./build/lib/index.js",
38
+ "test:unit": "mocha \"test/unit/**/*.spec.ts\""
42
39
  },
43
40
  "types": "./build/lib/index.d.ts",
44
41
  "dependencies": {
45
- "@appium/types": "^1.2.0",
46
- "axios": "1.13.3",
47
- "bluebird": "3.7.2",
42
+ "asyncbox": "6.1.0",
43
+ "axios": "1.13.6",
48
44
  "chai": "6.2.2",
49
45
  "chai-as-promised": "8.0.2",
50
46
  "get-port": "7.1.0",
51
47
  "lodash": "4.17.23",
52
- "sinon": "21.0.1",
53
- "type-fest": "5.4.1"
48
+ "sinon": "21.0.2",
49
+ "type-fest": "5.4.4"
50
+ },
51
+ "devDependencies": {
52
+ "@appium/types": "^1.2.1"
54
53
  },
55
54
  "peerDependencies": {
56
55
  "appium": "^3.0.0-beta.0",
@@ -63,5 +62,5 @@
63
62
  "publishConfig": {
64
63
  "access": "public"
65
64
  },
66
- "gitHead": "f7b20335eab4022e5cbbb627ec86866a994444f8"
65
+ "gitHead": "980a121804ae006db879fb6860f627ac36174c15"
67
66
  }
package/tsconfig.json CHANGED
@@ -3,12 +3,11 @@
3
3
  "compilerOptions": {
4
4
  "rootDir": ".",
5
5
  "outDir": "build",
6
- "checkJs": true,
7
6
  "paths": {
8
7
  "@appium/types": ["../types"],
9
8
  "appium/driver": ["../base-driver"]
10
9
  },
11
- "types": ["mocha", "chai", "chai-as-promised"]
10
+ "types": ["mocha", "chai", "chai-as-promised", "node"]
12
11
  },
13
12
  "include": ["lib", "test"],
14
13
  "references": [{"path": "../types"}, {"path": "../base-driver"}]
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./build/lib');
package/lib/helpers.js DELETED
@@ -1,68 +0,0 @@
1
- import getPort from 'get-port';
2
- import _ from 'lodash';
3
-
4
- /**
5
- * Default test host
6
- */
7
- const TEST_HOST = '127.0.0.1';
8
-
9
- let testPort;
10
-
11
- /**
12
- * Returns a free port; one per process
13
- * @param {boolean} [force] - If true, do not reuse the port (if it already exists)
14
- * @returns {Promise<number>} a free port
15
- */
16
- async function getTestPort(force = false) {
17
- if (force || !testPort) {
18
- let port = await getPort();
19
- if (!testPort) {
20
- testPort = port;
21
- }
22
- return port;
23
- }
24
- return testPort;
25
- }
26
-
27
- /**
28
- * Build an Appium URL from components.
29
- *
30
- * **All** parameters are required. Provide an empty string (`''`) if you don't need one.
31
- * To rearrange arguments (if needed), use the placeholder from Lodash (`_`).
32
- *
33
- */
34
- const createAppiumURL = _.curry(
35
- /**
36
- * @param {string} address - Base address (w/ optional protocol)
37
- * @param {string|number} port - Port number
38
- * @param {string?} session - Session ID
39
- * @param {string} pathname - Extra path
40
- * @returns {string} New URL
41
- * @example
42
- *
43
- * import _ from 'lodash';
44
- *
45
- * // http://127.0.0.1:31337/session
46
- * createAppiumURL('127.0.0.1', 31337, '', 'session')
47
- *
48
- * // http://127.0.0.1:31337/session/asdfgjkl
49
- * const createSessionURL = createAppiumURL('127.0.0.1', 31337, _, 'session')
50
- * createSessionURL('asdfgjkl')
51
- *
52
- * // http://127.0.0.1:31337/session/asdfgjkl/appium/execute
53
- * const createURLWithPath = createAppiumURL('127.0.0.1', 31337, 'asdfgjkl');
54
- * createURLWithPath('appium/execute')
55
- */
56
- (address, port, session, pathname) => {
57
- if (!/^https?:\/\//.test(address)) {
58
- address = `http://${address}`;
59
- }
60
- let path = session ? `session/${session}` : '';
61
- if (pathname) {
62
- path = `${path}/${pathname}`;
63
- }
64
- return new URL(path, `${address}:${port}`).href;
65
- }
66
- );
67
-
68
- export {TEST_HOST, getTestPort, createAppiumURL};
package/lib/index.js DELETED
@@ -1,13 +0,0 @@
1
- export {createSessionHelpers, driverE2ETestSuite} from './e2e-suite';
2
- export * from './unit-suite';
3
- export * from './helpers';
4
-
5
- /**
6
- * @typedef {import('@appium/types').DriverClass} DriverClass
7
- * @typedef {import('@appium/types').BaseNSCapabilities} BaseNSCapabilities
8
- */
9
-
10
- /**
11
- * @template {import('@appium/types').Constraints} C
12
- * @typedef {import('@appium/types').W3CCapabilities<C>} W3CCapabilities
13
- */