@tvlabs/wdio-service 0.1.0 → 0.1.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.
- package/README.md +13 -6
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +2 -3
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +2 -0
- package/dist/service.d.ts +3 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +40 -3
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ The `@tvlabs/wdio-service` package uses a websocket to connect to the TV Labs pl
|
|
|
14
14
|
|
|
15
15
|
The service first makes a session request, and then subscribes to events for that request. Once the session has been filled and is ready for the Webdriver script to begin, the service receives a ready event with the TV Labs session ID. This session ID is injected into the capabilities as `tvlabs:session_id` on the Webdriver session create request.
|
|
16
16
|
|
|
17
|
+
Additionally, the service adds a unique request ID for each request made. The service will generate and attach an `x-request-id` header before each request to the TV Labs platform. This can be used to correlate requests in the client side logs to the Appium server logs.
|
|
18
|
+
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
19
21
|
In your WebdriverIO project, run one of the following commands to install:
|
|
@@ -40,12 +42,10 @@ To use this as a WebdriverIO test runner service, include the service in your We
|
|
|
40
42
|
import TVLabsService from '@tvlabs/wdio-service';
|
|
41
43
|
|
|
42
44
|
export const config = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// ...
|
|
48
|
-
}
|
|
45
|
+
// ...
|
|
46
|
+
services: [[TVLabsService, { apiKey: process.env.TVLABS_API_KEY }]],
|
|
47
|
+
// ...
|
|
48
|
+
};
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### WebdriverIO Remote
|
|
@@ -113,3 +113,10 @@ run();
|
|
|
113
113
|
- **Required:** No
|
|
114
114
|
- **Default:** `5`
|
|
115
115
|
- **Description:** Maximum number of attempts to re-connect if the connection to TV Labs is lost.
|
|
116
|
+
|
|
117
|
+
### `attachRequestId`
|
|
118
|
+
|
|
119
|
+
- **Type:** `boolean`
|
|
120
|
+
- **Required:** No
|
|
121
|
+
- **Default:** `true`
|
|
122
|
+
- **Description:** Controls whether or not to attach an `x-request-id` header to each request made to the TV Labs platform.
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,YAAY,CAAC;AAGpB,qBAAa,aAAa;IAetB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,GAAG;IAhBb,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAU;IAE/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOZ;gBAGD,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,GAAG,EAAE,MAAM;IAaf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxB,UAAU,CACd,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,MAAM,EAClB,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC;YAWJ,WAAW;YAkBX,cAAc;IAkD5B,OAAO,CAAC,gBAAgB;YAUV,cAAc;YAuBd,IAAI;YAgBJ,IAAI;IAoBlB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;CAG1B"}
|
package/dist/channel.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Socket } from 'phoenix';
|
|
2
1
|
import WebSocket from 'ws';
|
|
3
|
-
import
|
|
2
|
+
import { Socket } from 'phoenix';
|
|
4
3
|
import { SevereServiceError } from 'webdriverio';
|
|
5
|
-
|
|
4
|
+
import { log } from './logger.js';
|
|
6
5
|
export class TVLabsChannel {
|
|
7
6
|
endpoint;
|
|
8
7
|
maxReconnectRetries;
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,eAAO,MAAM,GAAG,EAAE,MAAuC,CAAC"}
|
package/dist/logger.js
ADDED
package/dist/service.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ export default class TVLabsService implements Services.ServiceInstance {
|
|
|
7
7
|
constructor(_options: TVLabsServiceOptions, _capabilities: Capabilities.ResolvedTestrunnerCapabilities, _config: Options.WebdriverIO);
|
|
8
8
|
onPrepare(_config: Options.Testrunner, param: Capabilities.TestrunnerCapabilities): void;
|
|
9
9
|
beforeSession(_config: Omit<Options.Testrunner, 'capabilities'>, capabilities: TVLabsCapabilities, _specs: string[], _cid: string): Promise<void>;
|
|
10
|
+
private setupRequestId;
|
|
11
|
+
private setRequestHeader;
|
|
10
12
|
private endpoint;
|
|
11
13
|
private retries;
|
|
12
14
|
private apiKey;
|
|
15
|
+
private attachRequestId;
|
|
13
16
|
private reconnectRetries;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"
|
|
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,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,eAAe;IAElE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO;gBAFP,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,YAAY,CAAC,8BAA8B,EAC1D,OAAO,EAAE,OAAO,CAAC,WAAW;IAOtC,SAAS,CACP,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,KAAK,EAAE,YAAY,CAAC,sBAAsB;IAStC,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;IAkBd,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;CAGzB"}
|
package/dist/service.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SevereServiceError } from 'webdriverio';
|
|
2
|
+
import crypto from 'crypto';
|
|
3
|
+
import chalk from 'chalk';
|
|
2
4
|
import { TVLabsChannel } from './channel.js';
|
|
5
|
+
import { log } from './logger.js';
|
|
3
6
|
export default class TVLabsService {
|
|
4
7
|
_options;
|
|
5
8
|
_capabilities;
|
|
@@ -8,6 +11,9 @@ export default class TVLabsService {
|
|
|
8
11
|
this._options = _options;
|
|
9
12
|
this._capabilities = _capabilities;
|
|
10
13
|
this._config = _config;
|
|
14
|
+
if (this.attachRequestId()) {
|
|
15
|
+
this.setupRequestId();
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
onPrepare(_config, param) {
|
|
13
19
|
if (!Array.isArray(param)) {
|
|
@@ -20,16 +26,47 @@ export default class TVLabsService {
|
|
|
20
26
|
capabilities['tvlabs:session_id'] = await channel.newSession(capabilities, this.retries());
|
|
21
27
|
await channel.disconnect();
|
|
22
28
|
}
|
|
29
|
+
setupRequestId() {
|
|
30
|
+
const originalTransformRequest = this._config.transformRequest;
|
|
31
|
+
this._config.transformRequest = (requestOptions) => {
|
|
32
|
+
const requestId = crypto.randomUUID();
|
|
33
|
+
const originalRequestOptions = typeof originalTransformRequest === 'function'
|
|
34
|
+
? originalTransformRequest(requestOptions)
|
|
35
|
+
: requestOptions;
|
|
36
|
+
if (typeof originalRequestOptions.headers === 'undefined') {
|
|
37
|
+
originalRequestOptions.headers = {};
|
|
38
|
+
}
|
|
39
|
+
this.setRequestHeader(originalRequestOptions.headers, 'x-request-id', requestId);
|
|
40
|
+
log.info(chalk.blue('ATTACHED REQUEST ID'), requestId);
|
|
41
|
+
return originalRequestOptions;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
setRequestHeader(headers, header, value) {
|
|
45
|
+
if (headers instanceof Headers) {
|
|
46
|
+
headers.set(header, value);
|
|
47
|
+
}
|
|
48
|
+
else if (typeof headers === 'object') {
|
|
49
|
+
if (Array.isArray(headers)) {
|
|
50
|
+
headers.push([header, value]);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
headers[header] = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
23
57
|
endpoint() {
|
|
24
|
-
return this._options.endpoint
|
|
58
|
+
return this._options.endpoint ?? 'wss://tvlabs.ai/appium';
|
|
25
59
|
}
|
|
26
60
|
retries() {
|
|
27
|
-
return this._options.retries
|
|
61
|
+
return this._options.retries ?? 3;
|
|
28
62
|
}
|
|
29
63
|
apiKey() {
|
|
30
64
|
return this._options.apiKey;
|
|
31
65
|
}
|
|
66
|
+
attachRequestId() {
|
|
67
|
+
return this._options.attachRequestId ?? true;
|
|
68
|
+
}
|
|
32
69
|
reconnectRetries() {
|
|
33
|
-
return this._options.reconnectRetries
|
|
70
|
+
return this._options.reconnectRetries ?? 5;
|
|
34
71
|
}
|
|
35
72
|
}
|
package/dist/types.d.ts
CHANGED
package/dist/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,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC5B,YAAY,CAAC,+BAA+B,GAAG;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,kCAAkC,CAAC,EAAE,MAAM,CAAC;QAC5C,qBAAqB,CAAC,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEJ,MAAM,MAAM,gCAAgC,GAAG,CAC7C,QAAQ,EAAE,0BAA0B,KACjC,IAAI,CAAC;AAEV,MA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V,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tvlabs/wdio-service",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "WebdriverIO service that provides a better integration into TV Labs",
|
|
5
5
|
"author": "Regan Karlewicz <regan@tvlabs.ai>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"webdriverio": "^9.12.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
+
"chalk": "^5.1.2",
|
|
64
65
|
"phoenix": "^1.7.20",
|
|
65
66
|
"ws": "^8.18.1"
|
|
66
67
|
}
|