@wdio/browserstack-service 8.32.4 → 8.33.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.
- package/build/bstackLogger.d.ts +2 -1
- package/build/bstackLogger.d.ts.map +1 -1
- package/build/bstackLogger.js +6 -3
- package/build/cleanup.d.ts +5 -1
- package/build/cleanup.d.ts.map +1 -1
- package/build/cleanup.js +72 -7
- package/build/config.d.ts +23 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +39 -0
- package/build/constants.d.ts +14 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +22 -0
- package/build/crash-reporter.js +2 -2
- package/build/data-store.d.ts +4 -0
- package/build/data-store.d.ts.map +1 -0
- package/build/data-store.js +41 -0
- package/build/exitHandler.d.ts +4 -0
- package/build/exitHandler.d.ts.map +1 -0
- package/build/exitHandler.js +32 -0
- package/build/insights-handler.d.ts +5 -8
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +40 -93
- package/build/instrumentation/funnelInstrumentation.d.ts +6 -0
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -0
- package/build/instrumentation/funnelInstrumentation.js +119 -0
- package/build/launcher.d.ts +1 -1
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +22 -13
- package/build/reporter.d.ts +3 -3
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +11 -27
- package/build/request-handler.d.ts +5 -13
- package/build/request-handler.d.ts.map +1 -1
- package/build/request-handler.js +30 -48
- package/build/service.d.ts +1 -0
- package/build/service.d.ts.map +1 -1
- package/build/service.js +13 -5
- package/build/testOps/featureStats.d.ts +45 -0
- package/build/testOps/featureStats.d.ts.map +1 -0
- package/build/testOps/featureStats.js +116 -0
- package/build/testOps/featureUsage.d.ts +22 -0
- package/build/testOps/featureUsage.d.ts.map +1 -0
- package/build/testOps/featureUsage.js +47 -0
- package/build/testOps/listener.d.ts +33 -0
- package/build/testOps/listener.d.ts.map +1 -0
- package/build/testOps/listener.js +222 -0
- package/build/testOps/requestUtils.d.ts +4 -0
- package/build/testOps/requestUtils.d.ts.map +1 -0
- package/build/testOps/requestUtils.js +39 -0
- package/build/testOps/testOpsConfig.d.ts +11 -0
- package/build/testOps/testOpsConfig.d.ts.map +1 -0
- package/build/testOps/testOpsConfig.js +19 -0
- package/build/testOps/usageStats.d.ts +404 -0
- package/build/testOps/usageStats.d.ts.map +1 -0
- package/build/testOps/usageStats.js +114 -0
- package/build/types.d.ts +33 -7
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +3 -7
- package/build/util.d.ts.map +1 -1
- package/build/util.js +57 -77
- package/package.json +4 -4
package/build/bstackLogger.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class BStackLogger {
|
|
2
2
|
static logFilePath: string;
|
|
3
|
-
|
|
3
|
+
static logFolderPath: string;
|
|
4
4
|
private static logFileStream;
|
|
5
5
|
static logToFile(logMessage: string, logLevel: string): void;
|
|
6
6
|
private static formatLog;
|
|
@@ -11,5 +11,6 @@ export declare class BStackLogger {
|
|
|
11
11
|
static trace(message: string): void;
|
|
12
12
|
static clearLogger(): void;
|
|
13
13
|
static clearLogFile(): void;
|
|
14
|
+
static ensureLogsFolder(): void;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=bstackLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bstackLogger.d.ts","sourceRoot":"","sources":["../src/bstackLogger.ts"],"names":[],"mappings":"AAWA,qBAAa,YAAY;IACrB,OAAc,WAAW,SAAsC;IAC/D,
|
|
1
|
+
{"version":3,"file":"bstackLogger.d.ts","sourceRoot":"","sources":["../src/bstackLogger.ts"],"names":[],"mappings":"AAWA,qBAAa,YAAY;IACrB,OAAc,WAAW,SAAsC;IAC/D,OAAc,aAAa,SAAmC;IAC9D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAuB;IAEnD,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAcrD,OAAO,CAAC,MAAM,CAAC,SAAS;WAIV,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;WASlC,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,WAAW;WAOX,YAAY;WAMZ,gBAAgB;CAKjC"}
|
package/build/bstackLogger.js
CHANGED
|
@@ -12,9 +12,7 @@ export class BStackLogger {
|
|
|
12
12
|
static logToFile(logMessage, logLevel) {
|
|
13
13
|
try {
|
|
14
14
|
if (!this.logFileStream) {
|
|
15
|
-
|
|
16
|
-
fs.mkdirSync(this.logFolderPath);
|
|
17
|
-
}
|
|
15
|
+
this.ensureLogsFolder();
|
|
18
16
|
this.logFileStream = fs.createWriteStream(this.logFilePath, { flags: 'a' });
|
|
19
17
|
}
|
|
20
18
|
if (this.logFileStream && this.logFileStream.writable) {
|
|
@@ -64,4 +62,9 @@ export class BStackLogger {
|
|
|
64
62
|
fs.truncateSync(this.logFilePath);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
65
|
+
static ensureLogsFolder() {
|
|
66
|
+
if (!fs.existsSync(this.logFolderPath)) {
|
|
67
|
+
fs.mkdirSync(this.logFolderPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
67
70
|
}
|
package/build/cleanup.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export default class BStackCleanup {
|
|
2
2
|
static startCleanup(): Promise<void>;
|
|
3
|
-
static executeObservabilityCleanup(): Promise<void>;
|
|
3
|
+
static executeObservabilityCleanup(funnelData: any): Promise<void>;
|
|
4
|
+
static updateO11yStopData(funnelData: any, status: string, error?: unknown): void;
|
|
5
|
+
static sendFunnelData(funnelData: any): Promise<void>;
|
|
6
|
+
static getFunnelDataFromFile(filePath: string): any;
|
|
7
|
+
static removeFunnelDataFile(filePath?: string): void;
|
|
4
8
|
}
|
|
5
9
|
//# sourceMappingURL=cleanup.d.ts.map
|
package/build/cleanup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../src/cleanup.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,OAAO,aAAa;WACjB,YAAY;WAuBZ,2BAA2B,CAAC,UAAU,EAAE,GAAG;IAmBxD,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,OAAmB;WAkBxE,cAAc,CAAC,UAAU,EAAE,GAAG;IAS3C,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM;IAY7C,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM;CAMhD"}
|
package/build/cleanup.js
CHANGED
|
@@ -1,24 +1,89 @@
|
|
|
1
|
-
import { stopBuildUpstream } from './util.js';
|
|
1
|
+
import { getErrorString, stopBuildUpstream } from './util.js';
|
|
2
2
|
import { BStackLogger } from './bstackLogger.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { fireFunnelRequest } from './instrumentation/funnelInstrumentation.js';
|
|
5
|
+
import { TESTOPS_BUILD_ID_ENV, TESTOPS_JWT_ENV } from './constants.js';
|
|
3
6
|
export default class BStackCleanup {
|
|
4
7
|
static async startCleanup() {
|
|
5
8
|
try {
|
|
6
|
-
|
|
9
|
+
// Get funnel data object from saved file
|
|
10
|
+
const funnelDataCleanup = process.argv.includes('--funnelData');
|
|
11
|
+
let funnelData = null;
|
|
12
|
+
if (funnelDataCleanup) {
|
|
13
|
+
const index = process.argv.indexOf('--funnelData');
|
|
14
|
+
const filePath = process.argv[index + 1];
|
|
15
|
+
funnelData = this.getFunnelDataFromFile(filePath);
|
|
16
|
+
}
|
|
17
|
+
if (process.argv.includes('--observability')) {
|
|
18
|
+
await this.executeObservabilityCleanup(funnelData);
|
|
19
|
+
}
|
|
20
|
+
if (funnelDataCleanup && funnelData) {
|
|
21
|
+
await this.sendFunnelData(funnelData);
|
|
22
|
+
}
|
|
7
23
|
}
|
|
8
24
|
catch (err) {
|
|
9
25
|
const error = err;
|
|
10
26
|
BStackLogger.error(error);
|
|
11
27
|
}
|
|
12
28
|
}
|
|
13
|
-
static async executeObservabilityCleanup() {
|
|
14
|
-
if (!process.env
|
|
29
|
+
static async executeObservabilityCleanup(funnelData) {
|
|
30
|
+
if (!process.env[TESTOPS_JWT_ENV]) {
|
|
15
31
|
return;
|
|
16
32
|
}
|
|
17
33
|
BStackLogger.debug('Executing observability cleanup');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
try {
|
|
35
|
+
const result = await stopBuildUpstream();
|
|
36
|
+
if (process.env[TESTOPS_BUILD_ID_ENV]) {
|
|
37
|
+
BStackLogger.info(`\nVisit https://observability.browserstack.com/builds/${process.env[TESTOPS_BUILD_ID_ENV]} to view build report, insights, and many more debugging information all at one place!\n`);
|
|
38
|
+
}
|
|
39
|
+
const status = (result && result.status) || 'failed';
|
|
40
|
+
const message = (result && result.message);
|
|
41
|
+
this.updateO11yStopData(funnelData, status, status === 'failed' ? message : undefined);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
BStackLogger.error('Error in stopping Observability build: ' + e);
|
|
45
|
+
this.updateO11yStopData(funnelData, 'failed', e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static updateO11yStopData(funnelData, status, error = undefined) {
|
|
49
|
+
const toData = funnelData?.event_properties?.productUsage?.testObservability;
|
|
50
|
+
// Return if no O11y data in funnel data
|
|
51
|
+
if (!toData) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let existingStopData = toData.events.buildEvents.finished;
|
|
55
|
+
existingStopData = existingStopData || {};
|
|
56
|
+
existingStopData = {
|
|
57
|
+
...existingStopData,
|
|
58
|
+
status,
|
|
59
|
+
error: getErrorString(error),
|
|
60
|
+
stoppedFrom: 'exitHook'
|
|
61
|
+
};
|
|
62
|
+
toData.events.buildEvents.finished = existingStopData;
|
|
63
|
+
}
|
|
64
|
+
static async sendFunnelData(funnelData) {
|
|
65
|
+
try {
|
|
66
|
+
await fireFunnelRequest(funnelData);
|
|
67
|
+
BStackLogger.debug('Funnel data sent successfully from cleanup');
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
BStackLogger.error('Error in sending funnel data: ' + e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
static getFunnelDataFromFile(filePath) {
|
|
74
|
+
if (!filePath) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
78
|
+
const data = JSON.parse(content);
|
|
79
|
+
this.removeFunnelDataFile(filePath);
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
static removeFunnelDataFile(filePath) {
|
|
83
|
+
if (!filePath) {
|
|
84
|
+
return;
|
|
21
85
|
}
|
|
86
|
+
fs.rmSync(filePath, { force: true });
|
|
22
87
|
}
|
|
23
88
|
}
|
|
24
89
|
await BStackCleanup.startCleanup();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppConfig, BrowserstackConfig } from './types.js';
|
|
2
|
+
import type { Options } from '@wdio/types';
|
|
3
|
+
import TestOpsConfig from './testOps/testOpsConfig.js';
|
|
4
|
+
declare class BrowserStackConfig {
|
|
5
|
+
static getInstance(options?: BrowserstackConfig & Options.Testrunner, config?: Options.Testrunner): BrowserStackConfig;
|
|
6
|
+
userName?: string;
|
|
7
|
+
accessKey?: string;
|
|
8
|
+
framework?: string;
|
|
9
|
+
buildName?: string;
|
|
10
|
+
buildIdentifier?: string;
|
|
11
|
+
testObservability: TestOpsConfig;
|
|
12
|
+
percy: boolean;
|
|
13
|
+
accessibility: boolean;
|
|
14
|
+
app?: string | AppConfig;
|
|
15
|
+
private static _instance;
|
|
16
|
+
appAutomate: boolean;
|
|
17
|
+
automate: boolean;
|
|
18
|
+
funnelDataSent: boolean;
|
|
19
|
+
private constructor();
|
|
20
|
+
sentFunnelData(): void;
|
|
21
|
+
}
|
|
22
|
+
export default BrowserStackConfig;
|
|
23
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,aAAa,MAAM,4BAA4B,CAAA;AAGtD,cAAM,kBAAkB;IACpB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,GAAG,kBAAkB;IAO/G,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,aAAa,CAAA;IAChC,KAAK,EAAE,OAAO,CAAA;IACd,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,GAAC,SAAS,CAAA;IAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAoB;IACrC,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAQ;IAEtC,OAAO;IAaP,cAAc;CAIjB;AAED,eAAe,kBAAkB,CAAA"}
|
package/build/config.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import TestOpsConfig from './testOps/testOpsConfig.js';
|
|
2
|
+
import { isUndefined } from './util.js';
|
|
3
|
+
class BrowserStackConfig {
|
|
4
|
+
static getInstance(options, config) {
|
|
5
|
+
if (!this._instance && options && config) {
|
|
6
|
+
this._instance = new BrowserStackConfig(options, config);
|
|
7
|
+
}
|
|
8
|
+
return this._instance;
|
|
9
|
+
}
|
|
10
|
+
userName;
|
|
11
|
+
accessKey;
|
|
12
|
+
framework;
|
|
13
|
+
buildName;
|
|
14
|
+
buildIdentifier;
|
|
15
|
+
testObservability;
|
|
16
|
+
percy;
|
|
17
|
+
accessibility;
|
|
18
|
+
app;
|
|
19
|
+
static _instance;
|
|
20
|
+
appAutomate;
|
|
21
|
+
automate;
|
|
22
|
+
funnelDataSent = false;
|
|
23
|
+
constructor(options, config) {
|
|
24
|
+
this.framework = config.framework;
|
|
25
|
+
this.userName = config.user;
|
|
26
|
+
this.accessKey = config.key;
|
|
27
|
+
this.testObservability = new TestOpsConfig(options.testObservability !== false, !isUndefined(options.testObservability));
|
|
28
|
+
this.percy = options.percy || false;
|
|
29
|
+
this.accessibility = options.accessibility || false;
|
|
30
|
+
this.app = options.app;
|
|
31
|
+
this.appAutomate = !isUndefined(options.app);
|
|
32
|
+
this.automate = !this.appAutomate;
|
|
33
|
+
this.buildIdentifier = options.buildIdentifier;
|
|
34
|
+
}
|
|
35
|
+
sentFunnelData() {
|
|
36
|
+
this.funnelDataSent = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default BrowserStackConfig;
|
package/build/constants.d.ts
CHANGED
|
@@ -21,4 +21,18 @@ export declare const UPLOAD_LOGS_ENDPOINT = "client-logs/upload";
|
|
|
21
21
|
export declare const PERCY_LOGS_FILE = "logs/percy.log";
|
|
22
22
|
export declare const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS: string[];
|
|
23
23
|
export declare const CAPTURE_MODES: string[];
|
|
24
|
+
export declare const LOG_KIND_USAGE_MAP: {
|
|
25
|
+
TEST_LOG: string;
|
|
26
|
+
TEST_SCREENSHOT: string;
|
|
27
|
+
TEST_STEP: string;
|
|
28
|
+
HTTP: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const FUNNEL_INSTRUMENTATION_URL = "https://api.browserstack.com/sdk/v1/event";
|
|
31
|
+
export declare const TESTOPS_JWT_ENV = "BS_TESTOPS_JWT";
|
|
32
|
+
export declare const TESTOPS_SCREENSHOT_ENV = "BS_TESTOPS_ALLOW_SCREENSHOTS";
|
|
33
|
+
export declare const TESTOPS_BUILD_ID_ENV = "BS_TESTOPS_BUILD_HASHED_ID";
|
|
34
|
+
export declare const PERF_MEASUREMENT_ENV = "BROWSERSTACK_O11Y_PERF_MEASUREMENT";
|
|
35
|
+
export declare const RERUN_TESTS_ENV = "BROWSERSTACK_RERUN_TESTS";
|
|
36
|
+
export declare const RERUN_ENV = "BROWSERSTACK_RERUN";
|
|
37
|
+
export declare const TESTOPS_BUILD_COMPLETED_ENV = "BS_TESTOPS_BUILD_COMPLETED";
|
|
24
38
|
//# sourceMappingURL=constants.d.ts.map
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,eAAO,MAAM,mBAAmB,qHAStB,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,kBAAkB,CAKvD,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,OAAoC,CAAA;AAEvE,eAAO,MAAM,aAAa,qDAAqD,CAAA;AAC/E,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;A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AAA;AAC5D,eAAO,MAAM,yCAAyC,MAAM,CAAA;AAC5D,eAAO,MAAM,sBAAsB,KAAuB,CAAA;AAE1D,eAAO,MAAM,qBAAqB,+CAA+C,CAAA;AACjF,eAAO,MAAM,wBAAwB,UAA6D,CAAA;AAElG,eAAO,MAAM,SAAS,iCAAiC,CAAA;AACvD,eAAO,MAAM,mBAAmB,kDAAkD,CAAA;AAClF,eAAO,MAAM,oBAAoB,uBAAuB,CAAA;AAExD,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,eAAO,MAAM,qCAAqC,UAQjD,CAAA;AAED,eAAO,MAAM,aAAa,UAAwD,CAAA;AAElF,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAA;AAED,eAAO,MAAM,0BAA0B,8CAA8C,CAAA;AAKrF,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAG/C,eAAO,MAAM,sBAAsB,iCAAiC,CAAA;AAGpE,eAAO,MAAM,oBAAoB,+BAA+B,CAAA;AAGhE,eAAO,MAAM,oBAAoB,uCAAuC,CAAA;AAGxE,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAGzD,eAAO,MAAM,SAAS,uBAAuB,CAAA;AAG7C,eAAO,MAAM,2BAA2B,+BAA+B,CAAA"}
|
package/build/constants.js
CHANGED
|
@@ -49,3 +49,25 @@ export const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = [
|
|
|
49
49
|
'/session/:sessionId/appium/device/shake'
|
|
50
50
|
];
|
|
51
51
|
export const CAPTURE_MODES = ['click', 'auto', 'screenshot', 'manual', 'testcase'];
|
|
52
|
+
export const LOG_KIND_USAGE_MAP = {
|
|
53
|
+
'TEST_LOG': 'log',
|
|
54
|
+
'TEST_SCREENSHOT': 'screenshot',
|
|
55
|
+
'TEST_STEP': 'step',
|
|
56
|
+
'HTTP': 'http'
|
|
57
|
+
};
|
|
58
|
+
export const FUNNEL_INSTRUMENTATION_URL = 'https://api.browserstack.com/sdk/v1/event';
|
|
59
|
+
// Env variables - Define all the env variable constants over here
|
|
60
|
+
// To store the JWT token returned the session launch
|
|
61
|
+
export const TESTOPS_JWT_ENV = 'BS_TESTOPS_JWT';
|
|
62
|
+
// To store the setting of whether to send screenshots or not
|
|
63
|
+
export const TESTOPS_SCREENSHOT_ENV = 'BS_TESTOPS_ALLOW_SCREENSHOTS';
|
|
64
|
+
// To store build hashed id
|
|
65
|
+
export const TESTOPS_BUILD_ID_ENV = 'BS_TESTOPS_BUILD_HASHED_ID';
|
|
66
|
+
// Whether to collect performance instrumentation or not
|
|
67
|
+
export const PERF_MEASUREMENT_ENV = 'BROWSERSTACK_O11Y_PERF_MEASUREMENT';
|
|
68
|
+
// Whether the current run is rerun or not
|
|
69
|
+
export const RERUN_TESTS_ENV = 'BROWSERSTACK_RERUN_TESTS';
|
|
70
|
+
// The tests that needs to be rerun
|
|
71
|
+
export const RERUN_ENV = 'BROWSERSTACK_RERUN';
|
|
72
|
+
// To store whether the build launch has completed or not
|
|
73
|
+
export const TESTOPS_BUILD_COMPLETED_ENV = 'BS_TESTOPS_BUILD_COMPLETED';
|
package/build/crash-reporter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import got from 'got';
|
|
2
|
-
import { BSTACK_SERVICE_VERSION, DATA_ENDPOINT } from './constants.js';
|
|
2
|
+
import { BSTACK_SERVICE_VERSION, DATA_ENDPOINT, TESTOPS_BUILD_ID_ENV } from './constants.js';
|
|
3
3
|
import { DEFAULT_REQUEST_CONFIG, getObservabilityKey, getObservabilityUser } from './util.js';
|
|
4
4
|
import { BStackLogger } from './bstackLogger.js';
|
|
5
5
|
export default class CrashReporter {
|
|
@@ -52,7 +52,7 @@ export default class CrashReporter {
|
|
|
52
52
|
this.userConfigForReporting = {};
|
|
53
53
|
}
|
|
54
54
|
const data = {
|
|
55
|
-
hashed_id: process.env
|
|
55
|
+
hashed_id: process.env[TESTOPS_BUILD_ID_ENV],
|
|
56
56
|
observability_version: {
|
|
57
57
|
frameworkName: 'WebdriverIO-' + (this.userConfigForReporting.framework || 'null'),
|
|
58
58
|
sdkVersion: BSTACK_SERVICE_VERSION
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-store.d.ts","sourceRoot":"","sources":["../src/data-store.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,6BAoBjC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QASvD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAG9C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { BStackLogger } from './bstackLogger.js';
|
|
4
|
+
const workersDataDirPath = path.join(process.cwd(), 'logs', 'worker_data');
|
|
5
|
+
export function getDataFromWorkers() {
|
|
6
|
+
const workersData = [];
|
|
7
|
+
if (!fs.existsSync(workersDataDirPath)) {
|
|
8
|
+
return workersData;
|
|
9
|
+
}
|
|
10
|
+
const files = fs.readdirSync(workersDataDirPath);
|
|
11
|
+
files.forEach((file) => {
|
|
12
|
+
BStackLogger.debug('Reading worker file ' + file);
|
|
13
|
+
const filePath = path.join(workersDataDirPath, file);
|
|
14
|
+
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
15
|
+
const workerData = JSON.parse(fileContent);
|
|
16
|
+
workersData.push(workerData);
|
|
17
|
+
});
|
|
18
|
+
// Remove worker data after all reading
|
|
19
|
+
removeWorkersDataDir();
|
|
20
|
+
return workersData;
|
|
21
|
+
}
|
|
22
|
+
export function saveWorkerData(data) {
|
|
23
|
+
const filePath = path.join(workersDataDirPath, 'worker-data-' + process.pid + '.json');
|
|
24
|
+
try {
|
|
25
|
+
createWorkersDataDir();
|
|
26
|
+
fs.writeFileSync(filePath, JSON.stringify(data));
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
BStackLogger.debug('Exception in saving worker data: ' + e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function removeWorkersDataDir() {
|
|
33
|
+
fs.rmSync(workersDataDirPath, { recursive: true, force: true });
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function createWorkersDataDir() {
|
|
37
|
+
if (!fs.existsSync(workersDataDirPath)) {
|
|
38
|
+
fs.mkdirSync(workersDataDirPath, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitHandler.d.ts","sourceRoot":"","sources":["../src/exitHandler.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,aAAa,CAAA;AAS5C,wBAAgB,iBAAiB,SAWhC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAYtE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import BrowserStackConfig from './config.js';
|
|
4
|
+
import { saveFunnelData } from './instrumentation/funnelInstrumentation.js';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { TESTOPS_JWT_ENV } from './constants.js';
|
|
7
|
+
import { BStackLogger } from './bstackLogger.js';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
export function setupExitHandlers() {
|
|
11
|
+
process.on('exit', (code) => {
|
|
12
|
+
BStackLogger.debug('Exit hook called');
|
|
13
|
+
const args = shouldCallCleanup(BrowserStackConfig.getInstance());
|
|
14
|
+
if (Array.isArray(args) && args.length) {
|
|
15
|
+
BStackLogger.debug('Spawning cleanup with args ' + args.toString());
|
|
16
|
+
const childProcess = spawn('node', [`${path.join(__dirname, 'cleanup.js')}`, ...args], { detached: true, stdio: 'inherit', env: { ...process.env } });
|
|
17
|
+
childProcess.unref();
|
|
18
|
+
process.exit(code);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function shouldCallCleanup(config) {
|
|
23
|
+
const args = [];
|
|
24
|
+
if (!!process.env[TESTOPS_JWT_ENV] && !config.testObservability.buildStopped) {
|
|
25
|
+
args.push('--observability');
|
|
26
|
+
}
|
|
27
|
+
if (config.userName && config.accessKey && !config.funnelDataSent) {
|
|
28
|
+
const savedFilePath = saveFunnelData('SDKTestSuccessful', config);
|
|
29
|
+
args.push('--funnelData', savedFilePath);
|
|
30
|
+
}
|
|
31
|
+
return args;
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Frameworks } from '@wdio/types';
|
|
2
2
|
import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
|
|
3
3
|
import type { Feature, Scenario, CucumberHook, CucumberHookParams, Pickle, ITestCaseHookParameter } from './cucumber-types.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TestData, TestMeta, CurrentRunInfo, StdLog } from './types.js';
|
|
5
5
|
import type { Capabilities } from '@wdio/types';
|
|
6
6
|
declare class _InsightsHandler {
|
|
7
7
|
private _browser;
|
|
@@ -12,11 +12,11 @@ declare class _InsightsHandler {
|
|
|
12
12
|
private _commands;
|
|
13
13
|
private _gitConfigPath?;
|
|
14
14
|
private _suiteFile?;
|
|
15
|
-
private _requestQueueHandler;
|
|
16
15
|
private _currentTest;
|
|
17
16
|
private _currentHook;
|
|
18
17
|
private _cucumberData;
|
|
19
18
|
private _userCaps?;
|
|
19
|
+
private listener;
|
|
20
20
|
constructor(_browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isAppAutomate?: boolean, _framework?: string | undefined, _userCaps?: Capabilities.RemoteCapability);
|
|
21
21
|
registerListeners(): void;
|
|
22
22
|
setSuiteFile(filename: string): void;
|
|
@@ -30,7 +30,7 @@ declare class _InsightsHandler {
|
|
|
30
30
|
processCucumberHook(test: CucumberHook | undefined, params: CucumberHookParams, result?: Frameworks.TestResult): Promise<void>;
|
|
31
31
|
beforeHook(test: Frameworks.Test | CucumberHook | undefined, context: any): Promise<void>;
|
|
32
32
|
afterHook(test: Frameworks.Test | CucumberHook | undefined, result: Frameworks.TestResult): Promise<void>;
|
|
33
|
-
|
|
33
|
+
getHookRunDataForCucumber(hookData: TestMeta, eventType: string, result?: Frameworks.TestResult): TestData;
|
|
34
34
|
beforeTest(test: Frameworks.Test): Promise<void>;
|
|
35
35
|
afterTest(test: Frameworks.Test, result: Frameworks.TestResult): Promise<void>;
|
|
36
36
|
/**
|
|
@@ -41,21 +41,18 @@ declare class _InsightsHandler {
|
|
|
41
41
|
afterScenario(world: ITestCaseHookParameter): Promise<void>;
|
|
42
42
|
beforeStep(step: Frameworks.PickleStep, scenario: Pickle): Promise<void>;
|
|
43
43
|
afterStep(step: Frameworks.PickleStep, scenario: Pickle, result: Frameworks.PickleResult): Promise<void>;
|
|
44
|
-
uploadPending(waitTimeout?: number, waitInterval?: number): Promise<unknown>;
|
|
45
|
-
teardown(): Promise<void>;
|
|
46
44
|
/**
|
|
47
45
|
* misc methods
|
|
48
46
|
*/
|
|
49
47
|
appendTestItemLog: (stdLog: StdLog) => Promise<void>;
|
|
50
|
-
sendData(data: UploadType): Promise<void>;
|
|
51
48
|
browserCommand(commandType: string, args: BeforeCommandArgs | AfterCommandArgs, test?: Frameworks.Test | ITestCaseHookParameter): Promise<void>;
|
|
52
49
|
private attachHookData;
|
|
53
50
|
private setHooksFromSuite;
|
|
54
51
|
private getHierarchy;
|
|
55
|
-
private
|
|
52
|
+
private getRunData;
|
|
56
53
|
private getTestRunId;
|
|
57
54
|
private getTestRunIdFromSuite;
|
|
58
|
-
private
|
|
55
|
+
private getTestRunDataForCucumber;
|
|
59
56
|
private getIntegrationsObject;
|
|
60
57
|
private getIdentifier;
|
|
61
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"AAE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