@wdio/browserstack-service 7.34.0 → 7.36.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/Percy/Percy-Handler.d.ts +34 -0
- package/build/Percy/Percy-Handler.d.ts.map +1 -0
- package/build/Percy/Percy-Handler.js +187 -0
- package/build/Percy/Percy.d.ts +24 -0
- package/build/Percy/Percy.d.ts.map +1 -0
- package/build/Percy/Percy.js +128 -0
- package/build/Percy/PercyBinary.d.ts +17 -0
- package/build/Percy/PercyBinary.d.ts.map +1 -0
- package/build/Percy/PercyBinary.js +151 -0
- package/build/Percy/PercyCaptureMap.d.ts +9 -0
- package/build/Percy/PercyCaptureMap.d.ts.map +1 -0
- package/build/Percy/PercyCaptureMap.js +46 -0
- package/build/Percy/PercyHelper.d.ts +8 -0
- package/build/Percy/PercyHelper.d.ts.map +1 -0
- package/build/Percy/PercyHelper.js +78 -0
- package/build/Percy/PercyLogger.d.ts +15 -0
- package/build/Percy/PercyLogger.d.ts.map +1 -0
- package/build/Percy/PercyLogger.js +76 -0
- package/build/Percy/PercySDK.d.ts +4 -0
- package/build/Percy/PercySDK.d.ts.map +1 -0
- package/build/Percy/PercySDK.js +42 -0
- package/build/bstackLogger.d.ts +14 -0
- package/build/bstackLogger.d.ts.map +1 -0
- package/build/bstackLogger.js +52 -0
- package/build/cleanup.d.ts +6 -2
- package/build/cleanup.d.ts.map +1 -1
- package/build/cleanup.js +104 -12
- package/build/config.d.ts +23 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +32 -0
- package/build/constants.d.ts +20 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +45 -1
- package/build/crash-reporter.js +1 -1
- package/build/data-store.d.ts +3 -0
- package/build/data-store.d.ts.map +1 -0
- package/build/data-store.js +49 -0
- package/build/exitHandler.d.ts +4 -0
- package/build/exitHandler.d.ts.map +1 -0
- package/build/exitHandler.js +37 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +15 -1
- package/build/insights-handler.d.ts +5 -11
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +45 -106
- package/build/instrumentation/funnelInstrumentation.d.ts +6 -0
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -0
- package/build/instrumentation/funnelInstrumentation.js +127 -0
- package/build/launcher.d.ts +8 -4
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +87 -18
- package/build/reporter.d.ts +3 -3
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +10 -23
- package/build/request-handler.d.ts +5 -13
- package/build/request-handler.d.ts.map +1 -1
- package/build/request-handler.js +27 -48
- package/build/service.d.ts +3 -0
- package/build/service.d.ts.map +1 -1
- package/build/service.js +50 -18
- package/build/testOps/featureStats.d.ts +45 -0
- package/build/testOps/featureStats.d.ts.map +1 -0
- package/build/testOps/featureStats.js +120 -0
- package/build/testOps/featureUsage.d.ts +22 -0
- package/build/testOps/featureUsage.d.ts.map +1 -0
- package/build/testOps/featureUsage.js +46 -0
- package/build/testOps/listener.d.ts +33 -0
- package/build/testOps/listener.d.ts.map +1 -0
- package/build/testOps/listener.js +228 -0
- package/build/testOps/requestUtils.d.ts +4 -0
- package/build/testOps/requestUtils.d.ts.map +1 -0
- package/build/testOps/requestUtils.js +47 -0
- package/build/testOps/testOpsConfig.d.ts +11 -0
- package/build/testOps/testOpsConfig.d.ts.map +1 -0
- package/build/testOps/testOpsConfig.js +17 -0
- package/build/testOps/usageStats.d.ts +404 -0
- package/build/testOps/usageStats.d.ts.map +1 -0
- package/build/testOps/usageStats.js +110 -0
- package/build/types.d.ts +48 -7
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +4 -6
- package/build/util.d.ts.map +1 -1
- package/build/util.js +82 -67
- package/package.json +7 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveWorkerData = exports.getDataFromWorkers = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const bstackLogger_1 = require("./bstackLogger");
|
|
10
|
+
const workersDataDirPath = node_path_1.default.join(process.cwd(), 'logs', 'worker_data');
|
|
11
|
+
function getDataFromWorkers() {
|
|
12
|
+
const workersData = [];
|
|
13
|
+
if (!node_fs_1.default.existsSync(workersDataDirPath)) {
|
|
14
|
+
return workersData;
|
|
15
|
+
}
|
|
16
|
+
const files = node_fs_1.default.readdirSync(workersDataDirPath);
|
|
17
|
+
files.forEach((file) => {
|
|
18
|
+
bstackLogger_1.BStackLogger.debug('Reading worker file ' + file);
|
|
19
|
+
const filePath = node_path_1.default.join(workersDataDirPath, file);
|
|
20
|
+
const fileContent = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
21
|
+
const workerData = JSON.parse(fileContent);
|
|
22
|
+
workersData.push(workerData);
|
|
23
|
+
});
|
|
24
|
+
// Remove worker data after all reading
|
|
25
|
+
removeWorkersDataDir();
|
|
26
|
+
return workersData;
|
|
27
|
+
}
|
|
28
|
+
exports.getDataFromWorkers = getDataFromWorkers;
|
|
29
|
+
function saveWorkerData(data) {
|
|
30
|
+
const filePath = node_path_1.default.join(workersDataDirPath, 'worker-data-' + process.pid + '.json');
|
|
31
|
+
try {
|
|
32
|
+
createWorkersDataDir();
|
|
33
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(data));
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
bstackLogger_1.BStackLogger.debug('Exception in saving worker data: ' + e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.saveWorkerData = saveWorkerData;
|
|
40
|
+
function removeWorkersDataDir() {
|
|
41
|
+
node_fs_1.default.rmSync(workersDataDirPath, { recursive: true, force: true });
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function createWorkersDataDir() {
|
|
45
|
+
if (!node_fs_1.default.existsSync(workersDataDirPath)) {
|
|
46
|
+
node_fs_1.default.mkdirSync(workersDataDirPath, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exitHandler.d.ts","sourceRoot":"","sources":["../src/exitHandler.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,UAAU,CAAA;AAKzC,wBAAgB,iBAAiB,SAWhC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAYtE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.shouldCallCleanup = exports.setupExitHandlers = void 0;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const config_1 = __importDefault(require("./config"));
|
|
10
|
+
const funnelInstrumentation_1 = require("./instrumentation/funnelInstrumentation");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const bstackLogger_1 = require("./bstackLogger");
|
|
13
|
+
function setupExitHandlers() {
|
|
14
|
+
process.on('exit', (code) => {
|
|
15
|
+
bstackLogger_1.BStackLogger.debug('Exit hook called');
|
|
16
|
+
const args = shouldCallCleanup(config_1.default.getInstance());
|
|
17
|
+
if (Array.isArray(args) && args.length) {
|
|
18
|
+
bstackLogger_1.BStackLogger.debug('Spawning cleanup with args ' + args.toString());
|
|
19
|
+
const childProcess = (0, node_child_process_1.spawn)('node', [`${node_path_1.default.join(__dirname, 'cleanup.js')}`, ...args], { detached: true, stdio: 'inherit', env: { ...process.env } });
|
|
20
|
+
childProcess.unref();
|
|
21
|
+
process.exit(code);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.setupExitHandlers = setupExitHandlers;
|
|
26
|
+
function shouldCallCleanup(config) {
|
|
27
|
+
const args = [];
|
|
28
|
+
if (!!process.env[constants_1.TESTOPS_JWT_ENV] && !config.testObservability.buildStopped) {
|
|
29
|
+
args.push('--observability');
|
|
30
|
+
}
|
|
31
|
+
if (config.userName && config.accessKey && !config.funnelDataSent) {
|
|
32
|
+
const savedFilePath = (0, funnelInstrumentation_1.saveFunnelData)('SDKTestSuccessful', config);
|
|
33
|
+
args.push('--funnelData', savedFilePath);
|
|
34
|
+
}
|
|
35
|
+
return args;
|
|
36
|
+
}
|
|
37
|
+
exports.shouldCallCleanup = shouldCallCleanup;
|
package/build/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare const log4jsAppender: {
|
|
|
8
8
|
configure: (config: any, layouts: any) => Function;
|
|
9
9
|
};
|
|
10
10
|
export declare const BStackTestOpsLogger: typeof logReportingAPI;
|
|
11
|
+
import * as Percy from './Percy/PercySDK';
|
|
12
|
+
export declare const PercySDK: typeof Percy;
|
|
11
13
|
export * from './types';
|
|
12
14
|
declare global {
|
|
13
15
|
namespace WebdriverIO {
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,YAAY,CAAA;AAC7C,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,eAAO,MAAM,cAAc;;CAAgB,CAAA;AAC3C,eAAO,MAAM,mBAAmB,wBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,YAAY,CAAA;AAC7C,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,eAAO,MAAM,cAAc;;CAAgB,CAAA;AAC3C,eAAO,MAAM,mBAAmB,wBAAkB,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,eAAO,MAAM,QAAQ,cAAQ,CAAA;AAE7B,cAAc,SAAS,CAAA;AAEvB,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACxD;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -11,6 +11,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
12
|
o[k2] = m[k];
|
|
13
13
|
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
14
26
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
27
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
28
|
};
|
|
@@ -18,7 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
31
|
};
|
|
20
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.BStackTestOpsLogger = exports.log4jsAppender = exports.launcher = void 0;
|
|
33
|
+
exports.PercySDK = exports.BStackTestOpsLogger = exports.log4jsAppender = exports.launcher = void 0;
|
|
22
34
|
const launcher_1 = __importDefault(require("./launcher"));
|
|
23
35
|
const service_1 = __importDefault(require("./service"));
|
|
24
36
|
const log4jsAppender_1 = require("./log4jsAppender");
|
|
@@ -27,4 +39,6 @@ exports.default = service_1.default;
|
|
|
27
39
|
exports.launcher = launcher_1.default;
|
|
28
40
|
exports.log4jsAppender = { configure: log4jsAppender_1.configure };
|
|
29
41
|
exports.BStackTestOpsLogger = logReportingAPI_1.default;
|
|
42
|
+
const Percy = __importStar(require("./Percy/PercySDK"));
|
|
43
|
+
exports.PercySDK = Percy;
|
|
30
44
|
__exportStar(require("./types"), exports);
|
|
@@ -2,7 +2,7 @@ import type { Capabilities, Frameworks } from '@wdio/types';
|
|
|
2
2
|
import type { Browser, MultiRemoteBrowser } from 'webdriverio';
|
|
3
3
|
import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
|
|
4
4
|
import type { Feature, Scenario, CucumberHook, CucumberHookParams, Pickle, ITestCaseHookParameter } from './cucumber-types';
|
|
5
|
-
import type { TestMeta, CurrentRunInfo, StdLog } from './types';
|
|
5
|
+
import type { TestData, TestMeta, CurrentRunInfo, StdLog } from './types';
|
|
6
6
|
declare class _InsightsHandler {
|
|
7
7
|
private _browser;
|
|
8
8
|
private _framework?;
|
|
@@ -11,10 +11,10 @@ declare class _InsightsHandler {
|
|
|
11
11
|
private _platformMeta?;
|
|
12
12
|
private _commands;
|
|
13
13
|
private _gitConfigPath?;
|
|
14
|
-
private _requestQueueHandler;
|
|
15
14
|
private _currentTest;
|
|
16
15
|
private _currentHook;
|
|
17
16
|
private _cucumberData;
|
|
17
|
+
private listener;
|
|
18
18
|
constructor(_browser: Browser<'async'> | MultiRemoteBrowser<'async'>, browserCaps?: Capabilities.Capabilities, isAppAutomate?: boolean, sessionId?: string, _framework?: string | undefined);
|
|
19
19
|
registerListeners(): void;
|
|
20
20
|
before(): Promise<void>;
|
|
@@ -32,14 +32,8 @@ declare class _InsightsHandler {
|
|
|
32
32
|
afterStep(step: Frameworks.PickleStep, scenario: Pickle, result: Frameworks.PickleResult): Promise<void>;
|
|
33
33
|
sendScenarioObjectSkipped(scenario: Scenario, feature: Feature, uri: string): Promise<void>;
|
|
34
34
|
processCucumberHook(test: CucumberHook | undefined, params: CucumberHookParams, result?: Frameworks.TestResult): Promise<void>;
|
|
35
|
-
uploadPending(waitTimeout?: number, waitInterval?: number): any;
|
|
36
|
-
teardown(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* misc methods
|
|
39
|
-
*/
|
|
40
35
|
browserCommand(commandType: string, args: BeforeCommandArgs & AfterCommandArgs, test?: Frameworks.Test | ITestCaseHookParameter): Promise<void>;
|
|
41
36
|
appendTestItemLog: (stdLog: StdLog) => Promise<void>;
|
|
42
|
-
private sendData;
|
|
43
37
|
private attachHookData;
|
|
44
38
|
private setHooksFromSuite;
|
|
45
39
|
getCucumberHookType(test: CucumberHook | undefined): string | null;
|
|
@@ -50,9 +44,9 @@ declare class _InsightsHandler {
|
|
|
50
44
|
private getHierarchy;
|
|
51
45
|
private getTestRunId;
|
|
52
46
|
private getTestRunIdFromSuite;
|
|
53
|
-
private
|
|
54
|
-
private
|
|
55
|
-
|
|
47
|
+
private getRunData;
|
|
48
|
+
private getTestRunDataForCucumber;
|
|
49
|
+
getHookRunDataForCucumber(hookData: TestMeta, eventType: string, result?: Frameworks.TestResult): TestData;
|
|
56
50
|
private getIntegrationsObject;
|
|
57
51
|
private getIdentifier;
|
|
58
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAIzE,OAAO,KAAK,EAAiB,OAAO,EAAE,QAAQ,EAAsB,YAAY,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"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"}
|
|
@@ -8,7 +8,7 @@ const logger_1 = __importDefault(require("@wdio/logger"));
|
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
9
|
const reporter_1 = __importDefault(require("./reporter"));
|
|
10
10
|
const util_1 = require("./util");
|
|
11
|
-
const
|
|
11
|
+
const listener_1 = __importDefault(require("./testOps/listener"));
|
|
12
12
|
const constants_1 = require("./constants");
|
|
13
13
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
14
14
|
class _InsightsHandler {
|
|
@@ -18,7 +18,6 @@ class _InsightsHandler {
|
|
|
18
18
|
this._tests = {};
|
|
19
19
|
this._hooks = {};
|
|
20
20
|
this._commands = {};
|
|
21
|
-
this._requestQueueHandler = request_handler_1.default.getInstance();
|
|
22
21
|
this._currentTest = {};
|
|
23
22
|
this._currentHook = {};
|
|
24
23
|
this._cucumberData = {
|
|
@@ -26,6 +25,7 @@ class _InsightsHandler {
|
|
|
26
25
|
scenariosStarted: false,
|
|
27
26
|
steps: []
|
|
28
27
|
};
|
|
28
|
+
this.listener = listener_1.default.getInstance();
|
|
29
29
|
this.appendTestItemLog = async (stdLog) => {
|
|
30
30
|
try {
|
|
31
31
|
if (this._currentHook.uuid && !this._currentHook.finished && (this._framework === 'mocha' || this._framework === 'cucumber')) {
|
|
@@ -35,17 +35,13 @@ class _InsightsHandler {
|
|
|
35
35
|
stdLog.test_run_uuid = this._currentTest.uuid;
|
|
36
36
|
}
|
|
37
37
|
if (stdLog.hook_run_uuid || stdLog.test_run_uuid) {
|
|
38
|
-
|
|
39
|
-
event_type: 'LogCreated',
|
|
40
|
-
logs: [stdLog]
|
|
41
|
-
});
|
|
38
|
+
this.listener.logCreated([stdLog]);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
catch (error) {
|
|
45
42
|
log.debug(`Exception in uploading log data to Observability with error : ${error}`);
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
|
-
this._requestQueueHandler.start();
|
|
49
45
|
this._platformMeta = {
|
|
50
46
|
browserName: browserCaps === null || browserCaps === void 0 ? void 0 : browserCaps.browserName,
|
|
51
47
|
browserVersion: browserCaps === null || browserCaps === void 0 ? void 0 : browserCaps.browserVersion,
|
|
@@ -90,7 +86,7 @@ class _InsightsHandler {
|
|
|
90
86
|
};
|
|
91
87
|
this.setCurrentHook({ uuid: hookUUID });
|
|
92
88
|
this.attachHookData(context, hookUUID);
|
|
93
|
-
|
|
89
|
+
this.listener.hookStarted(this.getRunData(test, 'HookRunStarted'));
|
|
94
90
|
}
|
|
95
91
|
async afterHook(test, result) {
|
|
96
92
|
if (!(0, util_1.frameworkSupportsHook)('after', this._framework)) {
|
|
@@ -111,7 +107,7 @@ class _InsightsHandler {
|
|
|
111
107
|
};
|
|
112
108
|
}
|
|
113
109
|
this.setCurrentHook({ uuid: this._tests[fullTitle].uuid, finished: true });
|
|
114
|
-
|
|
110
|
+
this.listener.hookFinished(this.getRunData(test, 'HookRunFinished', result));
|
|
115
111
|
const hookType = (0, util_1.getHookType)(test.title);
|
|
116
112
|
/*
|
|
117
113
|
If any of the `beforeAll`, `beforeEach`, `afterEach` then the tests after the hook won't run in mocha (https://github.com/mochajs/mocha/issues/4392)
|
|
@@ -128,7 +124,7 @@ class _InsightsHandler {
|
|
|
128
124
|
startedAt: (new Date()).toISOString(),
|
|
129
125
|
finishedAt: (new Date()).toISOString()
|
|
130
126
|
};
|
|
131
|
-
|
|
127
|
+
this.listener.testFinished(this.getRunData(skippedTest, 'TestRunSkipped'));
|
|
132
128
|
}
|
|
133
129
|
};
|
|
134
130
|
/*
|
|
@@ -157,7 +153,7 @@ class _InsightsHandler {
|
|
|
157
153
|
uuid: uuid,
|
|
158
154
|
startedAt: (new Date()).toISOString()
|
|
159
155
|
};
|
|
160
|
-
|
|
156
|
+
this.listener.testStarted(this.getRunData(test, 'TestRunStarted'));
|
|
161
157
|
}
|
|
162
158
|
async afterTest(test, result) {
|
|
163
159
|
if (this._framework !== 'mocha')
|
|
@@ -167,7 +163,7 @@ class _InsightsHandler {
|
|
|
167
163
|
...(this._tests[fullTitle] || {}),
|
|
168
164
|
finishedAt: (new Date()).toISOString()
|
|
169
165
|
};
|
|
170
|
-
|
|
166
|
+
this.listener.testFinished(this.getRunData(test, 'TestRunFinished', result));
|
|
171
167
|
}
|
|
172
168
|
/**
|
|
173
169
|
* Cucumber Only
|
|
@@ -206,11 +202,11 @@ class _InsightsHandler {
|
|
|
206
202
|
};
|
|
207
203
|
}
|
|
208
204
|
this._tests[uniqueId] = testMetaData;
|
|
209
|
-
|
|
205
|
+
this.listener.testStarted(this.getTestRunDataForCucumber(world, 'TestRunStarted'));
|
|
210
206
|
}
|
|
211
207
|
async afterScenario(world) {
|
|
212
208
|
this._cucumberData.scenario = undefined;
|
|
213
|
-
|
|
209
|
+
this.listener.testFinished(this.getTestRunDataForCucumber(world, 'TestRunFinished'));
|
|
214
210
|
}
|
|
215
211
|
async beforeStep(step, scenario) {
|
|
216
212
|
var _a;
|
|
@@ -286,7 +282,7 @@ class _InsightsHandler {
|
|
|
286
282
|
};
|
|
287
283
|
}),
|
|
288
284
|
};
|
|
289
|
-
|
|
285
|
+
this.listener.testFinished(this.getTestRunDataForCucumber(null, 'TestRunSkipped', testMetaData));
|
|
290
286
|
}
|
|
291
287
|
async processCucumberHook(test, params, result) {
|
|
292
288
|
const hookType = this.getCucumberHookType(test);
|
|
@@ -307,12 +303,12 @@ class _InsightsHandler {
|
|
|
307
303
|
hookType: hookType
|
|
308
304
|
};
|
|
309
305
|
this._tests[hookId] = hookMetaData;
|
|
310
|
-
|
|
306
|
+
this.listener.hookStarted(this.getHookRunDataForCucumber(hookMetaData, 'HookRunStarted'));
|
|
311
307
|
}
|
|
312
308
|
else {
|
|
313
309
|
this._tests[hookId].finishedAt = (new Date()).toISOString();
|
|
314
310
|
this.setCurrentHook({ uuid: this._tests[hookId].uuid, finished: true });
|
|
315
|
-
|
|
311
|
+
this.listener.hookFinished(this.getHookRunDataForCucumber(this._tests[hookId], 'HookRunFinished', result));
|
|
316
312
|
if (hookType === 'BEFORE_ALL' && result && !result.passed) {
|
|
317
313
|
const { feature, uri } = this._cucumberData;
|
|
318
314
|
if (!feature) {
|
|
@@ -333,21 +329,6 @@ class _InsightsHandler {
|
|
|
333
329
|
}
|
|
334
330
|
}
|
|
335
331
|
}
|
|
336
|
-
//@ts-ignore
|
|
337
|
-
async uploadPending(waitTimeout = constants_1.DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS, waitInterval = constants_1.DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS) {
|
|
338
|
-
if (this._requestQueueHandler.pendingUploads <= 0 || waitTimeout <= 0) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
await (0, util_1.sleep)(waitInterval);
|
|
342
|
-
return this.uploadPending(waitTimeout - waitInterval);
|
|
343
|
-
}
|
|
344
|
-
async teardown() {
|
|
345
|
-
this._requestQueueHandler.tearDownInvoked = true;
|
|
346
|
-
await this._requestQueueHandler.shutdown();
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* misc methods
|
|
350
|
-
*/
|
|
351
332
|
async browserCommand(commandType, args, test) {
|
|
352
333
|
if (commandType === 'client:beforeCommand') {
|
|
353
334
|
this._commands[`${args.sessionId}_${args.method}_${args.endpoint}`] = args;
|
|
@@ -362,16 +343,13 @@ class _InsightsHandler {
|
|
|
362
343
|
return;
|
|
363
344
|
}
|
|
364
345
|
// log screenshot
|
|
365
|
-
if (Boolean(process.env.
|
|
366
|
-
await
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
kind: 'TEST_SCREENSHOT'
|
|
373
|
-
}]
|
|
374
|
-
}], constants_1.DATA_SCREENSHOT_ENDPOINT);
|
|
346
|
+
if (Boolean(process.env[constants_1.TESTOPS_SCREENSHOT_ENV]) && (0, util_1.isScreenshotCommand)(args) && args.result.value) {
|
|
347
|
+
await this.listener.onScreenshot([{
|
|
348
|
+
test_run_uuid: testMeta.uuid,
|
|
349
|
+
timestamp: new Date().toISOString(),
|
|
350
|
+
message: args.result.value,
|
|
351
|
+
kind: 'TEST_SCREENSHOT'
|
|
352
|
+
}]);
|
|
375
353
|
}
|
|
376
354
|
const dataKey = `${args.sessionId}_${args.method}_${args.endpoint}`;
|
|
377
355
|
const requestData = this._commands[dataKey];
|
|
@@ -379,32 +357,17 @@ class _InsightsHandler {
|
|
|
379
357
|
return;
|
|
380
358
|
}
|
|
381
359
|
// log http request
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
}]
|
|
395
|
-
});
|
|
396
|
-
if (req.proceed && req.data) {
|
|
397
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
/*
|
|
401
|
-
* private methods
|
|
402
|
-
*/
|
|
403
|
-
async sendData(data) {
|
|
404
|
-
const req = this._requestQueueHandler.add(data);
|
|
405
|
-
if (req.proceed && req.data) {
|
|
406
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
407
|
-
}
|
|
360
|
+
this.listener.logCreated([{
|
|
361
|
+
test_run_uuid: testMeta.uuid,
|
|
362
|
+
timestamp: new Date().toISOString(),
|
|
363
|
+
kind: 'HTTP',
|
|
364
|
+
http_response: {
|
|
365
|
+
path: requestData.endpoint,
|
|
366
|
+
method: requestData.method,
|
|
367
|
+
body: requestData.body,
|
|
368
|
+
response: args.result
|
|
369
|
+
}
|
|
370
|
+
}]);
|
|
408
371
|
}
|
|
409
372
|
attachHookData(context, hookId) {
|
|
410
373
|
if (context.currentTest && context.currentTest.parent) {
|
|
@@ -542,7 +505,7 @@ class _InsightsHandler {
|
|
|
542
505
|
}
|
|
543
506
|
return;
|
|
544
507
|
}
|
|
545
|
-
|
|
508
|
+
getRunData(test, eventType, results) {
|
|
546
509
|
var _a;
|
|
547
510
|
const fullTitle = (0, util_1.getUniqueIdentifier)(test, this._framework);
|
|
548
511
|
const testMetaData = this._tests[fullTitle];
|
|
@@ -595,24 +558,14 @@ class _InsightsHandler {
|
|
|
595
558
|
testData.result = 'skipped';
|
|
596
559
|
eventType = 'TestRunFinished';
|
|
597
560
|
}
|
|
598
|
-
const uploadData = {
|
|
599
|
-
event_type: eventType,
|
|
600
|
-
};
|
|
601
561
|
/* istanbul ignore if */
|
|
602
562
|
if (eventType.match(/HookRun/)) {
|
|
603
563
|
testData.hook_type = ((_a = testData.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ? (0, util_1.getHookType)(testData.name.toLowerCase()) : 'undefined';
|
|
604
564
|
testData.test_run_id = this.getTestRunId(test.ctx);
|
|
605
|
-
uploadData.hook_run = testData;
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
uploadData.test_run = testData;
|
|
609
|
-
}
|
|
610
|
-
const req = this._requestQueueHandler.add(uploadData);
|
|
611
|
-
if (req.proceed && req.data) {
|
|
612
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
613
565
|
}
|
|
566
|
+
return testData;
|
|
614
567
|
}
|
|
615
|
-
|
|
568
|
+
getTestRunDataForCucumber(worldObj, eventType, testMetaData = null) {
|
|
616
569
|
const world = worldObj;
|
|
617
570
|
const dataHub = testMetaData ? testMetaData : (this._tests[(0, util_1.getUniqueIdentifierForCucumber)(world)] || {});
|
|
618
571
|
const { feature, scenario, steps, uuid, startedAt, finishedAt } = dataHub;
|
|
@@ -686,18 +639,10 @@ class _InsightsHandler {
|
|
|
686
639
|
}
|
|
687
640
|
if (eventType === 'TestRunSkipped') {
|
|
688
641
|
testData.result = 'skipped';
|
|
689
|
-
eventType = 'TestRunFinished';
|
|
690
|
-
}
|
|
691
|
-
const uploadData = {
|
|
692
|
-
event_type: eventType,
|
|
693
|
-
test_run: testData
|
|
694
|
-
};
|
|
695
|
-
const req = this._requestQueueHandler.add(uploadData);
|
|
696
|
-
if (req.proceed && req.data) {
|
|
697
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
698
642
|
}
|
|
643
|
+
return testData;
|
|
699
644
|
}
|
|
700
|
-
|
|
645
|
+
getHookRunDataForCucumber(hookData, eventType, result) {
|
|
701
646
|
const { uri, feature } = this._cucumberData;
|
|
702
647
|
const testData = {
|
|
703
648
|
uuid: hookData.uuid,
|
|
@@ -734,24 +679,18 @@ class _InsightsHandler {
|
|
|
734
679
|
testData.integrations[provider] = this.getIntegrationsObject();
|
|
735
680
|
}
|
|
736
681
|
}
|
|
737
|
-
|
|
738
|
-
event_type: eventType,
|
|
739
|
-
hook_run: testData
|
|
740
|
-
};
|
|
741
|
-
const req = this._requestQueueHandler.add(uploadData);
|
|
742
|
-
if (req.proceed && req.data) {
|
|
743
|
-
await (0, util_1.uploadEventData)(req.data, req.url);
|
|
744
|
-
}
|
|
682
|
+
return testData;
|
|
745
683
|
}
|
|
746
684
|
getIntegrationsObject() {
|
|
747
|
-
var _a, _b
|
|
685
|
+
var _a, _b;
|
|
686
|
+
const browserCaps = this._browser.capabilities;
|
|
748
687
|
return {
|
|
749
|
-
capabilities:
|
|
750
|
-
session_id: (
|
|
751
|
-
browser:
|
|
752
|
-
browser_version:
|
|
753
|
-
platform:
|
|
754
|
-
product: (
|
|
688
|
+
capabilities: browserCaps,
|
|
689
|
+
session_id: (_a = this._browser) === null || _a === void 0 ? void 0 : _a.sessionId,
|
|
690
|
+
browser: browserCaps === null || browserCaps === void 0 ? void 0 : browserCaps.browserName,
|
|
691
|
+
browser_version: browserCaps === null || browserCaps === void 0 ? void 0 : browserCaps.browserVersion,
|
|
692
|
+
platform: browserCaps === null || browserCaps === void 0 ? void 0 : browserCaps.platformName,
|
|
693
|
+
product: (_b = this._platformMeta) === null || _b === void 0 ? void 0 : _b.product
|
|
755
694
|
};
|
|
756
695
|
}
|
|
757
696
|
getIdentifier(test) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type BrowserStackConfig from '../config';
|
|
2
|
+
export declare function sendStart(config: BrowserStackConfig): Promise<void>;
|
|
3
|
+
export declare function sendFinish(config: BrowserStackConfig): Promise<void>;
|
|
4
|
+
export declare function saveFunnelData(eventType: string, config: BrowserStackConfig): string;
|
|
5
|
+
export declare function fireFunnelRequest(data: any): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=funnelInstrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"funnelInstrumentation.d.ts","sourceRoot":"","sources":["../../src/instrumentation/funnelInstrumentation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,kBAAkB,MAAM,WAAW,CAAA;AAsB/C,wBAAsB,SAAS,CAAC,MAAM,EAAE,kBAAkB,iBAEzD;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,kBAAkB,iBAE1D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAOpF;AAGD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhE"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fireFunnelRequest = exports.saveFunnelData = exports.sendFinish = exports.sendStart = void 0;
|
|
7
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
8
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const got_1 = __importDefault(require("got"));
|
|
12
|
+
const usageStats_1 = __importDefault(require("../testOps/usageStats"));
|
|
13
|
+
const bstackLogger_1 = require("../bstackLogger");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const data_store_1 = require("../data-store");
|
|
16
|
+
async function fireFunnelTestEvent(eventType, config) {
|
|
17
|
+
if (!config.userName || !config.accessKey) {
|
|
18
|
+
bstackLogger_1.BStackLogger.debug('username/accesskey not passed');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const data = buildEventData(eventType, config);
|
|
23
|
+
await fireFunnelRequest(data);
|
|
24
|
+
bstackLogger_1.BStackLogger.debug('Funnel event success');
|
|
25
|
+
if (eventType === 'SDKTestSuccessful') {
|
|
26
|
+
config.sentFunnelData();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
bstackLogger_1.BStackLogger.debug('Exception in sending funnel data: ' + error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function sendStart(config) {
|
|
34
|
+
await fireFunnelTestEvent('SDKTestAttempted', config);
|
|
35
|
+
}
|
|
36
|
+
exports.sendStart = sendStart;
|
|
37
|
+
async function sendFinish(config) {
|
|
38
|
+
await fireFunnelTestEvent('SDKTestSuccessful', config);
|
|
39
|
+
}
|
|
40
|
+
exports.sendFinish = sendFinish;
|
|
41
|
+
function saveFunnelData(eventType, config) {
|
|
42
|
+
const data = buildEventData(eventType, config);
|
|
43
|
+
bstackLogger_1.BStackLogger.ensureLogsFolder();
|
|
44
|
+
const filePath = node_path_1.default.join(bstackLogger_1.BStackLogger.logFolderPath, 'funnelData.json');
|
|
45
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(data));
|
|
46
|
+
return filePath;
|
|
47
|
+
}
|
|
48
|
+
exports.saveFunnelData = saveFunnelData;
|
|
49
|
+
// Called from two different process
|
|
50
|
+
async function fireFunnelRequest(data) {
|
|
51
|
+
bstackLogger_1.BStackLogger.debug('Sending SDK event with data ' + node_util_1.default.inspect(data, { depth: 6 }));
|
|
52
|
+
await got_1.default.post(constants_1.FUNNEL_INSTRUMENTATION_URL, {
|
|
53
|
+
headers: {
|
|
54
|
+
'content-type': 'application/json'
|
|
55
|
+
}, username: data.userName, password: data.accessKey, json: data
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.fireFunnelRequest = fireFunnelRequest;
|
|
59
|
+
function getProductList(config) {
|
|
60
|
+
const products = [];
|
|
61
|
+
if (config.testObservability.enabled) {
|
|
62
|
+
products.push('observability');
|
|
63
|
+
}
|
|
64
|
+
if (config.accessibility) {
|
|
65
|
+
products.push('accessibility');
|
|
66
|
+
}
|
|
67
|
+
if (config.percy) {
|
|
68
|
+
products.push('percy');
|
|
69
|
+
}
|
|
70
|
+
if (config.automate) {
|
|
71
|
+
products.push('automate');
|
|
72
|
+
}
|
|
73
|
+
if (config.appAutomate) {
|
|
74
|
+
products.push('app-automate');
|
|
75
|
+
}
|
|
76
|
+
return products;
|
|
77
|
+
}
|
|
78
|
+
function getProductMap(config) {
|
|
79
|
+
return {
|
|
80
|
+
'observability': config.testObservability.enabled,
|
|
81
|
+
'accessibility': config.accessibility,
|
|
82
|
+
'percy': config.percy,
|
|
83
|
+
'automate': config.automate,
|
|
84
|
+
'app_automate': config.appAutomate
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function buildEventData(eventType, config) {
|
|
88
|
+
const eventProperties = {
|
|
89
|
+
// Framework Details
|
|
90
|
+
language_framework: getLanguageFramework(config.framework),
|
|
91
|
+
referrer: getReferrer(config.framework),
|
|
92
|
+
language: 'WebdriverIO',
|
|
93
|
+
languageVersion: process.version,
|
|
94
|
+
// Build Details
|
|
95
|
+
buildName: config.buildName || 'undefined',
|
|
96
|
+
buildIdentifier: String(config.buildIdentifier),
|
|
97
|
+
// Host details
|
|
98
|
+
os: node_os_1.default.type() || 'unknown',
|
|
99
|
+
hostname: node_os_1.default.hostname() || 'unknown',
|
|
100
|
+
// Product Details
|
|
101
|
+
productMap: getProductMap(config),
|
|
102
|
+
product: getProductList(config),
|
|
103
|
+
};
|
|
104
|
+
if (eventType === 'SDKTestSuccessful') {
|
|
105
|
+
const workerData = (0, data_store_1.getDataFromWorkers)();
|
|
106
|
+
eventProperties.productUsage = getProductUsage(workerData);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
userName: config.userName,
|
|
110
|
+
accessKey: config.accessKey,
|
|
111
|
+
event_type: eventType,
|
|
112
|
+
detectedFramework: 'WebdriverIO-' + config.framework,
|
|
113
|
+
event_properties: eventProperties
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function getProductUsage(workersData) {
|
|
117
|
+
return {
|
|
118
|
+
testObservability: usageStats_1.default.getInstance().getFormattedData(workersData)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function getLanguageFramework(framework) {
|
|
122
|
+
return 'WebdriverIO_' + framework;
|
|
123
|
+
}
|
|
124
|
+
function getReferrer(framework) {
|
|
125
|
+
const fullName = framework ? 'WebdriverIO-' + framework : 'WebdriverIO';
|
|
126
|
+
return `${fullName}/${constants_1.BSTACK_SERVICE_VERSION}`;
|
|
127
|
+
}
|