@tvlabs/wdio-service 0.1.7 → 0.1.9
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.
- package/README.md +45 -2
- package/cjs/index.js +43 -16
- package/cjs/service.d.ts +4 -0
- package/cjs/service.d.ts.map +1 -1
- package/cjs/types.d.ts +1 -0
- package/cjs/types.d.ts.map +1 -1
- package/esm/index.js +43 -16
- package/esm/service.d.ts +4 -0
- package/esm/service.d.ts.map +1 -1
- package/esm/types.d.ts +1 -0
- package/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/service.ts +62 -31
- package/src/types.ts +1 -0
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
## Introduction
|
|
12
12
|
|
|
13
|
+
[](https://www.npmjs.com/package/@tvlabs/wdio-service)
|
|
14
|
+
|
|
13
15
|
The `@tvlabs/wdio-service` package uses a websocket to connect to the TV Labs platform before an Appium session begins, logging events relating to build upload and session creation as they occur. This offloads the responsibility of creating the TV Labs session from the `POST /session` Webdriver endpoint, leading to more reliable session requests and creation.
|
|
14
16
|
|
|
15
17
|
If a build path is provided, the service first makes a build upload request to the TV Labs platform, and then sets the `tvlabs:build` capability to the newly created build ID.
|
|
@@ -74,7 +76,10 @@ async function run() {
|
|
|
74
76
|
apiKey: process.env.TVLABS_API_TOKEN,
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
// NOTE: it is important to make sure that
|
|
80
|
+
// the wdOpts passed here are the same reference
|
|
81
|
+
// as the one passed to remote()
|
|
82
|
+
const service = new TVLabsService(serviceOpts, capabilities, wdOpts)
|
|
78
83
|
|
|
79
84
|
// The TV Labs service does not use specs or a cid, pass default values.
|
|
80
85
|
const cid = ""
|
|
@@ -112,7 +117,7 @@ run();
|
|
|
112
117
|
|
|
113
118
|
- **Type:** `string`
|
|
114
119
|
- **Required:** No
|
|
115
|
-
- **Description:**
|
|
120
|
+
- **Description:** The slug of the app on the TV Labs platform to use to upload the build. When not provided, the organization's default app is used. You may find or create an app on the [Apps page](https://tvlabs.ai/app/apps) in the TV Labs platform.
|
|
116
121
|
|
|
117
122
|
### `retries`
|
|
118
123
|
|
|
@@ -134,3 +139,41 @@ run();
|
|
|
134
139
|
- **Required:** No
|
|
135
140
|
- **Default:** `true`
|
|
136
141
|
- **Description:** Controls whether or not to attach an `x-request-id` header to each request made to the TV Labs platform.
|
|
142
|
+
|
|
143
|
+
### `continueOnError`
|
|
144
|
+
|
|
145
|
+
- **Type:** `boolean`
|
|
146
|
+
- **Required:** No
|
|
147
|
+
- **Default:** `false`
|
|
148
|
+
- **Description:** Whether to continue the session request if any step fails. When `true`, the session request will still be made with the original provided capabilities. When `false`, the service will exit with a non-zero code.
|
|
149
|
+
|
|
150
|
+
## Methods
|
|
151
|
+
|
|
152
|
+
### `lastRequestId()`
|
|
153
|
+
|
|
154
|
+
- **Returns:** `string | undefined`
|
|
155
|
+
- **Description:** Returns the last request ID that was attached to a request made to the TV Labs platform. This is useful for correlating client-side logs with server-side logs. Returns `undefined` if no request has been made yet or if `attachRequestId` is set to `false`.
|
|
156
|
+
|
|
157
|
+
#### Example
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
import { remote } from 'webdriverio';
|
|
161
|
+
import { TVLabsService } from '@tvlabs/wdio-service';
|
|
162
|
+
|
|
163
|
+
const capabilities = { ... };
|
|
164
|
+
const wdOpts = { ... };
|
|
165
|
+
|
|
166
|
+
const service = new TVLabsService(
|
|
167
|
+
{ apiKey: process.env.TVLABS_API_KEY },
|
|
168
|
+
capabilities,
|
|
169
|
+
wdOpts
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
await service.beforeSession(wdOpts, capabilities, [], '');
|
|
173
|
+
|
|
174
|
+
const driver = await remote(wdOpts);
|
|
175
|
+
|
|
176
|
+
// Get the last request ID
|
|
177
|
+
const requestId = service.lastRequestId();
|
|
178
|
+
console.log(`Last request ID: ${requestId}`);
|
|
179
|
+
```
|
package/cjs/index.js
CHANGED
|
@@ -136,7 +136,7 @@ class Logger {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
var name = "@tvlabs/wdio-service";
|
|
139
|
-
var version = "0.1.
|
|
139
|
+
var version = "0.1.9";
|
|
140
140
|
var packageJson = {
|
|
141
141
|
name: name,
|
|
142
142
|
version: version};
|
|
@@ -453,32 +453,52 @@ class TVLabsService {
|
|
|
453
453
|
_capabilities;
|
|
454
454
|
_config;
|
|
455
455
|
log;
|
|
456
|
+
requestId;
|
|
456
457
|
constructor(_options, _capabilities, _config) {
|
|
457
458
|
this._options = _options;
|
|
458
459
|
this._capabilities = _capabilities;
|
|
459
460
|
this._config = _config;
|
|
460
|
-
this.log = new Logger('@tvlabs/wdio-
|
|
461
|
+
this.log = new Logger('@tvlabs/wdio-service', this._config.logLevel);
|
|
461
462
|
if (this.attachRequestId()) {
|
|
462
463
|
this.setupRequestId();
|
|
463
464
|
}
|
|
464
465
|
}
|
|
466
|
+
lastRequestId() {
|
|
467
|
+
return this.requestId;
|
|
468
|
+
}
|
|
465
469
|
onPrepare(_config, param) {
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
try {
|
|
471
|
+
if (!Array.isArray(param)) {
|
|
472
|
+
throw new webdriverio.SevereServiceError('Multi-remote capabilities are not implemented. Contact TV Labs support if you are interested in this feature.');
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
if (!this.continueOnError()) {
|
|
477
|
+
process.exit(1);
|
|
478
|
+
}
|
|
479
|
+
throw error;
|
|
468
480
|
}
|
|
469
481
|
}
|
|
470
482
|
async beforeSession(_config, capabilities, _specs, _cid) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
483
|
+
try {
|
|
484
|
+
const buildPath = this.buildPath();
|
|
485
|
+
if (buildPath) {
|
|
486
|
+
const buildChannel = new BuildChannel(this.buildEndpoint(), this.reconnectRetries(), this.apiKey(), this.logLevel());
|
|
487
|
+
await buildChannel.connect();
|
|
488
|
+
capabilities['tvlabs:build'] = await buildChannel.uploadBuild(buildPath, this.appSlug());
|
|
489
|
+
await buildChannel.disconnect();
|
|
490
|
+
}
|
|
491
|
+
const sessionChannel = new SessionChannel(this.sessionEndpoint(), this.reconnectRetries(), this.apiKey(), this.logLevel());
|
|
492
|
+
await sessionChannel.connect();
|
|
493
|
+
capabilities['tvlabs:session_id'] = await sessionChannel.newSession(capabilities, this.retries());
|
|
494
|
+
await sessionChannel.disconnect();
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
if (!this.continueOnError()) {
|
|
498
|
+
process.exit(1);
|
|
499
|
+
}
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
482
502
|
}
|
|
483
503
|
setupRequestId() {
|
|
484
504
|
const originalTransformRequest = this._config.transformRequest;
|
|
@@ -491,7 +511,8 @@ class TVLabsService {
|
|
|
491
511
|
originalRequestOptions.headers = {};
|
|
492
512
|
}
|
|
493
513
|
this.setRequestHeader(originalRequestOptions.headers, 'x-request-id', requestId);
|
|
494
|
-
this.log.
|
|
514
|
+
this.log.debug('ATTACHED REQUEST ID', requestId);
|
|
515
|
+
this.setRequestId(requestId);
|
|
495
516
|
return originalRequestOptions;
|
|
496
517
|
};
|
|
497
518
|
}
|
|
@@ -508,6 +529,12 @@ class TVLabsService {
|
|
|
508
529
|
}
|
|
509
530
|
}
|
|
510
531
|
}
|
|
532
|
+
setRequestId(id) {
|
|
533
|
+
this.requestId = id;
|
|
534
|
+
}
|
|
535
|
+
continueOnError() {
|
|
536
|
+
return this._options.continueOnError ?? false;
|
|
537
|
+
}
|
|
511
538
|
buildPath() {
|
|
512
539
|
return this._options.buildPath;
|
|
513
540
|
}
|
package/cjs/service.d.ts
CHANGED
|
@@ -5,11 +5,15 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
5
5
|
private _capabilities;
|
|
6
6
|
private _config;
|
|
7
7
|
private log;
|
|
8
|
+
private requestId;
|
|
8
9
|
constructor(_options: TVLabsServiceOptions, _capabilities: Capabilities.ResolvedTestrunnerCapabilities, _config: Options.WebdriverIO);
|
|
10
|
+
lastRequestId(): string | undefined;
|
|
9
11
|
onPrepare(_config: Options.Testrunner, param: Capabilities.TestrunnerCapabilities): void;
|
|
10
12
|
beforeSession(_config: Omit<Options.Testrunner, 'capabilities'>, capabilities: TVLabsCapabilities, _specs: string[], _cid: string): Promise<void>;
|
|
11
13
|
private setupRequestId;
|
|
12
14
|
private setRequestHeader;
|
|
15
|
+
private setRequestId;
|
|
16
|
+
private continueOnError;
|
|
13
17
|
private buildPath;
|
|
14
18
|
private appSlug;
|
|
15
19
|
private sessionEndpoint;
|
package/cjs/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,eAAe;IAKlE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO;IANjB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAAqB;gBAG5B,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,YAAY,CAAC,8BAA8B,EAC1D,OAAO,EAAE,OAAO,CAAC,WAAW;IAQtC,aAAa,IAAI,MAAM,GAAG,SAAS;IAInC,SAAS,CACP,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,KAAK,EAAE,YAAY,CAAC,sBAAsB;IAiBtC,aAAa,CACjB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,EACjD,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,MAAM;IA+Cd,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;CAGzB"}
|
package/cjs/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type TVLabsServiceOptions = {
|
|
|
9
9
|
app?: string;
|
|
10
10
|
reconnectRetries?: number;
|
|
11
11
|
attachRequestId?: boolean;
|
|
12
|
+
continueOnError?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type TVLabsCapabilities = Capabilities.RequestedStandaloneCapabilities & {
|
|
14
15
|
'tvlabs:session_id'?: string;
|
package/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,M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CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -110,7 +110,7 @@ class Logger {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
var name = "@tvlabs/wdio-service";
|
|
113
|
-
var version = "0.1.
|
|
113
|
+
var version = "0.1.9";
|
|
114
114
|
var packageJson = {
|
|
115
115
|
name: name,
|
|
116
116
|
version: version};
|
|
@@ -427,32 +427,52 @@ class TVLabsService {
|
|
|
427
427
|
_capabilities;
|
|
428
428
|
_config;
|
|
429
429
|
log;
|
|
430
|
+
requestId;
|
|
430
431
|
constructor(_options, _capabilities, _config) {
|
|
431
432
|
this._options = _options;
|
|
432
433
|
this._capabilities = _capabilities;
|
|
433
434
|
this._config = _config;
|
|
434
|
-
this.log = new Logger('@tvlabs/wdio-
|
|
435
|
+
this.log = new Logger('@tvlabs/wdio-service', this._config.logLevel);
|
|
435
436
|
if (this.attachRequestId()) {
|
|
436
437
|
this.setupRequestId();
|
|
437
438
|
}
|
|
438
439
|
}
|
|
440
|
+
lastRequestId() {
|
|
441
|
+
return this.requestId;
|
|
442
|
+
}
|
|
439
443
|
onPrepare(_config, param) {
|
|
440
|
-
|
|
441
|
-
|
|
444
|
+
try {
|
|
445
|
+
if (!Array.isArray(param)) {
|
|
446
|
+
throw new SevereServiceError('Multi-remote capabilities are not implemented. Contact TV Labs support if you are interested in this feature.');
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
if (!this.continueOnError()) {
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
453
|
+
throw error;
|
|
442
454
|
}
|
|
443
455
|
}
|
|
444
456
|
async beforeSession(_config, capabilities, _specs, _cid) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
457
|
+
try {
|
|
458
|
+
const buildPath = this.buildPath();
|
|
459
|
+
if (buildPath) {
|
|
460
|
+
const buildChannel = new BuildChannel(this.buildEndpoint(), this.reconnectRetries(), this.apiKey(), this.logLevel());
|
|
461
|
+
await buildChannel.connect();
|
|
462
|
+
capabilities['tvlabs:build'] = await buildChannel.uploadBuild(buildPath, this.appSlug());
|
|
463
|
+
await buildChannel.disconnect();
|
|
464
|
+
}
|
|
465
|
+
const sessionChannel = new SessionChannel(this.sessionEndpoint(), this.reconnectRetries(), this.apiKey(), this.logLevel());
|
|
466
|
+
await sessionChannel.connect();
|
|
467
|
+
capabilities['tvlabs:session_id'] = await sessionChannel.newSession(capabilities, this.retries());
|
|
468
|
+
await sessionChannel.disconnect();
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
if (!this.continueOnError()) {
|
|
472
|
+
process.exit(1);
|
|
473
|
+
}
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
456
476
|
}
|
|
457
477
|
setupRequestId() {
|
|
458
478
|
const originalTransformRequest = this._config.transformRequest;
|
|
@@ -465,7 +485,8 @@ class TVLabsService {
|
|
|
465
485
|
originalRequestOptions.headers = {};
|
|
466
486
|
}
|
|
467
487
|
this.setRequestHeader(originalRequestOptions.headers, 'x-request-id', requestId);
|
|
468
|
-
this.log.
|
|
488
|
+
this.log.debug('ATTACHED REQUEST ID', requestId);
|
|
489
|
+
this.setRequestId(requestId);
|
|
469
490
|
return originalRequestOptions;
|
|
470
491
|
};
|
|
471
492
|
}
|
|
@@ -482,6 +503,12 @@ class TVLabsService {
|
|
|
482
503
|
}
|
|
483
504
|
}
|
|
484
505
|
}
|
|
506
|
+
setRequestId(id) {
|
|
507
|
+
this.requestId = id;
|
|
508
|
+
}
|
|
509
|
+
continueOnError() {
|
|
510
|
+
return this._options.continueOnError ?? false;
|
|
511
|
+
}
|
|
485
512
|
buildPath() {
|
|
486
513
|
return this._options.buildPath;
|
|
487
514
|
}
|
package/esm/service.d.ts
CHANGED
|
@@ -5,11 +5,15 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
5
5
|
private _capabilities;
|
|
6
6
|
private _config;
|
|
7
7
|
private log;
|
|
8
|
+
private requestId;
|
|
8
9
|
constructor(_options: TVLabsServiceOptions, _capabilities: Capabilities.ResolvedTestrunnerCapabilities, _config: Options.WebdriverIO);
|
|
10
|
+
lastRequestId(): string | undefined;
|
|
9
11
|
onPrepare(_config: Options.Testrunner, param: Capabilities.TestrunnerCapabilities): void;
|
|
10
12
|
beforeSession(_config: Omit<Options.Testrunner, 'capabilities'>, capabilities: TVLabsCapabilities, _specs: string[], _cid: string): Promise<void>;
|
|
11
13
|
private setupRequestId;
|
|
12
14
|
private setRequestHeader;
|
|
15
|
+
private setRequestId;
|
|
16
|
+
private continueOnError;
|
|
13
17
|
private buildPath;
|
|
14
18
|
private appSlug;
|
|
15
19
|
private sessionEndpoint;
|
package/esm/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,eAAe;IAKlE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO;IANjB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAAqB;gBAG5B,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,YAAY,CAAC,8BAA8B,EAC1D,OAAO,EAAE,OAAO,CAAC,WAAW;IAQtC,aAAa,IAAI,MAAM,GAAG,SAAS;IAInC,SAAS,CACP,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,KAAK,EAAE,YAAY,CAAC,sBAAsB;IAiBtC,aAAa,CACjB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,EACjD,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,MAAM;IA+Cd,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;CAGzB"}
|
package/esm/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type TVLabsServiceOptions = {
|
|
|
9
9
|
app?: string;
|
|
10
10
|
reconnectRetries?: number;
|
|
11
11
|
attachRequestId?: boolean;
|
|
12
|
+
continueOnError?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type TVLabsCapabilities = Capabilities.RequestedStandaloneCapabilities & {
|
|
14
15
|
'tvlabs:session_id'?: string;
|
package/esm/types.d.ts.map
CHANGED
|
@@ -1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B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/package.json
CHANGED
package/src/service.ts
CHANGED
|
@@ -14,26 +14,39 @@ import type {
|
|
|
14
14
|
|
|
15
15
|
export default class TVLabsService implements Services.ServiceInstance {
|
|
16
16
|
private log: Logger;
|
|
17
|
+
private requestId: string | undefined;
|
|
17
18
|
|
|
18
19
|
constructor(
|
|
19
20
|
private _options: TVLabsServiceOptions,
|
|
20
21
|
private _capabilities: Capabilities.ResolvedTestrunnerCapabilities,
|
|
21
22
|
private _config: Options.WebdriverIO,
|
|
22
23
|
) {
|
|
23
|
-
this.log = new Logger('@tvlabs/wdio-
|
|
24
|
+
this.log = new Logger('@tvlabs/wdio-service', this._config.logLevel);
|
|
24
25
|
if (this.attachRequestId()) {
|
|
25
26
|
this.setupRequestId();
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
lastRequestId(): string | undefined {
|
|
31
|
+
return this.requestId;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
onPrepare(
|
|
30
35
|
_config: Options.Testrunner,
|
|
31
36
|
param: Capabilities.TestrunnerCapabilities,
|
|
32
37
|
) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
try {
|
|
39
|
+
if (!Array.isArray(param)) {
|
|
40
|
+
throw new SevereServiceError(
|
|
41
|
+
'Multi-remote capabilities are not implemented. Contact TV Labs support if you are interested in this feature.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (!this.continueOnError()) {
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
throw error;
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
|
|
@@ -43,41 +56,49 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
43
56
|
_specs: string[],
|
|
44
57
|
_cid: string,
|
|
45
58
|
) {
|
|
46
|
-
|
|
59
|
+
try {
|
|
60
|
+
const buildPath = this.buildPath();
|
|
61
|
+
|
|
62
|
+
if (buildPath) {
|
|
63
|
+
const buildChannel = new BuildChannel(
|
|
64
|
+
this.buildEndpoint(),
|
|
65
|
+
this.reconnectRetries(),
|
|
66
|
+
this.apiKey(),
|
|
67
|
+
this.logLevel(),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await buildChannel.connect();
|
|
71
|
+
|
|
72
|
+
capabilities['tvlabs:build'] = await buildChannel.uploadBuild(
|
|
73
|
+
buildPath,
|
|
74
|
+
this.appSlug(),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
await buildChannel.disconnect();
|
|
78
|
+
}
|
|
47
79
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.buildEndpoint(),
|
|
80
|
+
const sessionChannel = new SessionChannel(
|
|
81
|
+
this.sessionEndpoint(),
|
|
51
82
|
this.reconnectRetries(),
|
|
52
83
|
this.apiKey(),
|
|
53
84
|
this.logLevel(),
|
|
54
85
|
);
|
|
55
86
|
|
|
56
|
-
await
|
|
87
|
+
await sessionChannel.connect();
|
|
57
88
|
|
|
58
|
-
capabilities['tvlabs:
|
|
59
|
-
|
|
60
|
-
this.
|
|
89
|
+
capabilities['tvlabs:session_id'] = await sessionChannel.newSession(
|
|
90
|
+
capabilities,
|
|
91
|
+
this.retries(),
|
|
61
92
|
);
|
|
62
93
|
|
|
63
|
-
await
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.reconnectRetries(),
|
|
69
|
-
this.apiKey(),
|
|
70
|
-
this.logLevel(),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
await sessionChannel.connect();
|
|
74
|
-
|
|
75
|
-
capabilities['tvlabs:session_id'] = await sessionChannel.newSession(
|
|
76
|
-
capabilities,
|
|
77
|
-
this.retries(),
|
|
78
|
-
);
|
|
94
|
+
await sessionChannel.disconnect();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (!this.continueOnError()) {
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
79
99
|
|
|
80
|
-
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
81
102
|
}
|
|
82
103
|
|
|
83
104
|
private setupRequestId() {
|
|
@@ -100,7 +121,9 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
100
121
|
requestId,
|
|
101
122
|
);
|
|
102
123
|
|
|
103
|
-
this.log.
|
|
124
|
+
this.log.debug('ATTACHED REQUEST ID', requestId);
|
|
125
|
+
|
|
126
|
+
this.setRequestId(requestId);
|
|
104
127
|
|
|
105
128
|
return originalRequestOptions;
|
|
106
129
|
};
|
|
@@ -122,6 +145,14 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
122
145
|
}
|
|
123
146
|
}
|
|
124
147
|
|
|
148
|
+
private setRequestId(id: string) {
|
|
149
|
+
this.requestId = id;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private continueOnError(): boolean {
|
|
153
|
+
return this._options.continueOnError ?? false;
|
|
154
|
+
}
|
|
155
|
+
|
|
125
156
|
private buildPath(): string | undefined {
|
|
126
157
|
return this._options.buildPath;
|
|
127
158
|
}
|