@wdio/browserstack-service 0.0.0-canary-20260722132416
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/LICENSE-MIT +20 -0
- package/README.md +392 -0
- package/browserstack-service.d.ts +43 -0
- package/build/Percy/Percy-Handler.d.ts +32 -0
- package/build/Percy/Percy-Handler.d.ts.map +1 -0
- package/build/Percy/Percy-Handler.js +165 -0
- package/build/Percy/Percy-Handler.js.map +1 -0
- package/build/Percy/Percy.d.ts +19 -0
- package/build/Percy/Percy.d.ts.map +1 -0
- package/build/Percy/Percy.js +164 -0
- package/build/Percy/Percy.js.map +1 -0
- package/build/Percy/PercyBinary.d.ts +10 -0
- package/build/Percy/PercyBinary.d.ts.map +1 -0
- package/build/Percy/PercyBinary.js +161 -0
- package/build/Percy/PercyBinary.js.map +1 -0
- package/build/Percy/PercyCaptureMap.d.ts +9 -0
- package/build/Percy/PercyCaptureMap.d.ts.map +1 -0
- package/build/Percy/PercyCaptureMap.js +36 -0
- package/build/Percy/PercyCaptureMap.js.map +1 -0
- package/build/Percy/PercyHelper.d.ts +8 -0
- package/build/Percy/PercyHelper.d.ts.map +1 -0
- package/build/Percy/PercyHelper.js +68 -0
- package/build/Percy/PercyHelper.js.map +1 -0
- package/build/Percy/PercyLogger.d.ts +15 -0
- package/build/Percy/PercyLogger.d.ts.map +1 -0
- package/build/Percy/PercyLogger.js +68 -0
- package/build/Percy/PercyLogger.js.map +1 -0
- package/build/Percy/PercySDK.d.ts +4 -0
- package/build/Percy/PercySDK.d.ts.map +1 -0
- package/build/Percy/PercySDK.js +86 -0
- package/build/Percy/PercySDK.js.map +1 -0
- package/build/accessibility-handler.d.ts +52 -0
- package/build/accessibility-handler.d.ts.map +1 -0
- package/build/accessibility-handler.js +361 -0
- package/build/accessibility-handler.js.map +1 -0
- package/build/ai-handler.d.ts +23 -0
- package/build/ai-handler.d.ts.map +1 -0
- package/build/ai-handler.js +184 -0
- package/build/ai-handler.js.map +1 -0
- package/build/bstackLogger.d.ts +16 -0
- package/build/bstackLogger.d.ts.map +1 -0
- package/build/bstackLogger.js +71 -0
- package/build/bstackLogger.js.map +1 -0
- package/build/cleanup.d.ts +9 -0
- package/build/cleanup.d.ts.map +1 -0
- package/build/cleanup.js +101 -0
- package/build/cleanup.js.map +1 -0
- package/build/cli/apiUtils.d.ts +14 -0
- package/build/cli/apiUtils.d.ts.map +1 -0
- package/build/cli/apiUtils.js +25 -0
- package/build/cli/apiUtils.js.map +1 -0
- package/build/cli/cliLogger.d.ts +17 -0
- package/build/cli/cliLogger.d.ts.map +1 -0
- package/build/cli/cliLogger.js +82 -0
- package/build/cli/cliLogger.js.map +1 -0
- package/build/cli/cliUtils.d.ts +64 -0
- package/build/cli/cliUtils.d.ts.map +1 -0
- package/build/cli/cliUtils.js +461 -0
- package/build/cli/cliUtils.js.map +1 -0
- package/build/cli/eventDispatcher.d.ts +28 -0
- package/build/cli/eventDispatcher.d.ts.map +1 -0
- package/build/cli/eventDispatcher.js +49 -0
- package/build/cli/eventDispatcher.js.map +1 -0
- package/build/cli/frameworks/automationFramework.d.ts +89 -0
- package/build/cli/frameworks/automationFramework.d.ts.map +1 -0
- package/build/cli/frameworks/automationFramework.js +132 -0
- package/build/cli/frameworks/automationFramework.js.map +1 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts +18 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts.map +1 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.js +18 -0
- package/build/cli/frameworks/constants/automationFrameworkConstants.js.map +1 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.d.ts +43 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.d.ts.map +1 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.js +43 -0
- package/build/cli/frameworks/constants/testFrameworkConstants.js.map +1 -0
- package/build/cli/frameworks/testFramework.d.ts +89 -0
- package/build/cli/frameworks/testFramework.d.ts.map +1 -0
- package/build/cli/frameworks/testFramework.js +126 -0
- package/build/cli/frameworks/testFramework.js.map +1 -0
- package/build/cli/frameworks/wdioAutomationFramework.d.ts +28 -0
- package/build/cli/frameworks/wdioAutomationFramework.d.ts.map +1 -0
- package/build/cli/frameworks/wdioAutomationFramework.js +67 -0
- package/build/cli/frameworks/wdioAutomationFramework.js.map +1 -0
- package/build/cli/frameworks/wdioMochaTestFramework.d.ts +82 -0
- package/build/cli/frameworks/wdioMochaTestFramework.d.ts.map +1 -0
- package/build/cli/frameworks/wdioMochaTestFramework.js +322 -0
- package/build/cli/frameworks/wdioMochaTestFramework.js.map +1 -0
- package/build/cli/grpcClient.d.ts +86 -0
- package/build/cli/grpcClient.d.ts.map +1 -0
- package/build/cli/grpcClient.js +532 -0
- package/build/cli/grpcClient.js.map +1 -0
- package/build/cli/index.d.ts +150 -0
- package/build/cli/index.d.ts.map +1 -0
- package/build/cli/index.js +464 -0
- package/build/cli/index.js.map +1 -0
- package/build/cli/instances/automationFrameworkInstance.d.ts +33 -0
- package/build/cli/instances/automationFrameworkInstance.d.ts.map +1 -0
- package/build/cli/instances/automationFrameworkInstance.js +45 -0
- package/build/cli/instances/automationFrameworkInstance.js.map +1 -0
- package/build/cli/instances/testFrameworkInstance.d.ts +62 -0
- package/build/cli/instances/testFrameworkInstance.d.ts.map +1 -0
- package/build/cli/instances/testFrameworkInstance.js +97 -0
- package/build/cli/instances/testFrameworkInstance.js.map +1 -0
- package/build/cli/instances/trackedContext.d.ts +32 -0
- package/build/cli/instances/trackedContext.d.ts.map +1 -0
- package/build/cli/instances/trackedContext.js +48 -0
- package/build/cli/instances/trackedContext.js.map +1 -0
- package/build/cli/instances/trackedInstance.d.ts +40 -0
- package/build/cli/instances/trackedInstance.d.ts.map +1 -0
- package/build/cli/instances/trackedInstance.js +64 -0
- package/build/cli/instances/trackedInstance.js.map +1 -0
- package/build/cli/modules/accessibilityModule.d.ts +46 -0
- package/build/cli/modules/accessibilityModule.d.ts.map +1 -0
- package/build/cli/modules/accessibilityModule.js +447 -0
- package/build/cli/modules/accessibilityModule.js.map +1 -0
- package/build/cli/modules/automateModule.d.ts +26 -0
- package/build/cli/modules/automateModule.d.ts.map +1 -0
- package/build/cli/modules/automateModule.js +223 -0
- package/build/cli/modules/automateModule.js.map +1 -0
- package/build/cli/modules/baseModule.d.ts +33 -0
- package/build/cli/modules/baseModule.d.ts.map +1 -0
- package/build/cli/modules/baseModule.js +52 -0
- package/build/cli/modules/baseModule.js.map +1 -0
- package/build/cli/modules/observabilityModule.d.ts +22 -0
- package/build/cli/modules/observabilityModule.d.ts.map +1 -0
- package/build/cli/modules/observabilityModule.js +46 -0
- package/build/cli/modules/observabilityModule.js.map +1 -0
- package/build/cli/modules/percyModule.d.ts +19 -0
- package/build/cli/modules/percyModule.d.ts.map +1 -0
- package/build/cli/modules/percyModule.js +78 -0
- package/build/cli/modules/percyModule.js.map +1 -0
- package/build/cli/modules/testHubModule.d.ts +30 -0
- package/build/cli/modules/testHubModule.d.ts.map +1 -0
- package/build/cli/modules/testHubModule.js +233 -0
- package/build/cli/modules/testHubModule.js.map +1 -0
- package/build/cli/modules/webdriverIOModule.d.ts +29 -0
- package/build/cli/modules/webdriverIOModule.d.ts.map +1 -0
- package/build/cli/modules/webdriverIOModule.js +129 -0
- package/build/cli/modules/webdriverIOModule.js.map +1 -0
- package/build/cli/states/automationFrameworkState.d.ts +65 -0
- package/build/cli/states/automationFrameworkState.d.ts.map +1 -0
- package/build/cli/states/automationFrameworkState.js +62 -0
- package/build/cli/states/automationFrameworkState.js.map +1 -0
- package/build/cli/states/hookState.d.ts +45 -0
- package/build/cli/states/hookState.d.ts.map +1 -0
- package/build/cli/states/hookState.js +44 -0
- package/build/cli/states/hookState.js.map +1 -0
- package/build/cli/states/testFrameworkState.d.ts +125 -0
- package/build/cli/states/testFrameworkState.d.ts.map +1 -0
- package/build/cli/states/testFrameworkState.js +116 -0
- package/build/cli/states/testFrameworkState.js.map +1 -0
- package/build/config.d.ts +29 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +52 -0
- package/build/config.js.map +1 -0
- package/build/constants.d.ts +96 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +156 -0
- package/build/constants.js.map +1 -0
- package/build/crash-reporter.d.ts +18 -0
- package/build/crash-reporter.d.ts.map +1 -0
- package/build/crash-reporter.js +134 -0
- package/build/crash-reporter.js.map +1 -0
- package/build/cucumber-types.d.ts +194 -0
- package/build/cucumber-types.d.ts.map +1 -0
- package/build/cucumber-types.js +2 -0
- package/build/cucumber-types.js.map +1 -0
- package/build/data-store.d.ts +4 -0
- package/build/data-store.d.ts.map +1 -0
- package/build/data-store.js +42 -0
- package/build/data-store.js.map +1 -0
- package/build/exitHandler.d.ts +4 -0
- package/build/exitHandler.d.ts.map +1 -0
- package/build/exitHandler.js +105 -0
- package/build/exitHandler.js.map +1 -0
- package/build/fileStream.d.ts +9 -0
- package/build/fileStream.d.ts.map +1 -0
- package/build/fileStream.js +13 -0
- package/build/fileStream.js.map +1 -0
- package/build/grpc/generated/sdk-messages-accessibility.d.ts +76 -0
- package/build/grpc/generated/sdk-messages-accessibility.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages-accessibility.js +908 -0
- package/build/grpc/generated/sdk-messages-accessibility.js.map +1 -0
- package/build/grpc/generated/sdk-messages-ai.d.ts +52 -0
- package/build/grpc/generated/sdk-messages-ai.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages-ai.js +643 -0
- package/build/grpc/generated/sdk-messages-ai.js.map +1 -0
- package/build/grpc/generated/sdk-messages-observability.d.ts +44 -0
- package/build/grpc/generated/sdk-messages-observability.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages-observability.js +505 -0
- package/build/grpc/generated/sdk-messages-observability.js.map +1 -0
- package/build/grpc/generated/sdk-messages-percy.d.ts +16 -0
- package/build/grpc/generated/sdk-messages-percy.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages-percy.js +111 -0
- package/build/grpc/generated/sdk-messages-percy.js.map +1 -0
- package/build/grpc/generated/sdk-messages-testhub.d.ts +16 -0
- package/build/grpc/generated/sdk-messages-testhub.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages-testhub.js +132 -0
- package/build/grpc/generated/sdk-messages-testhub.js.map +1 -0
- package/build/grpc/generated/sdk-messages.d.ts +288 -0
- package/build/grpc/generated/sdk-messages.d.ts.map +1 -0
- package/build/grpc/generated/sdk-messages.js +3958 -0
- package/build/grpc/generated/sdk-messages.js.map +1 -0
- package/build/grpc/generated/sdk.d.ts +282 -0
- package/build/grpc/generated/sdk.d.ts.map +1 -0
- package/build/grpc/generated/sdk.js +197 -0
- package/build/grpc/generated/sdk.js.map +1 -0
- package/build/grpc/index.d.ts +43 -0
- package/build/grpc/index.d.ts.map +1 -0
- package/build/grpc/index.js +154 -0
- package/build/grpc/index.js.map +1 -0
- package/build/index.d.ts +20 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +13 -0
- package/build/index.js.map +1 -0
- package/build/insights-handler.d.ts +76 -0
- package/build/insights-handler.d.ts.map +1 -0
- package/build/insights-handler.js +855 -0
- package/build/insights-handler.js.map +1 -0
- package/build/instrumentation/funnelInstrumentation.d.ts +8 -0
- package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -0
- package/build/instrumentation/funnelInstrumentation.js +235 -0
- package/build/instrumentation/funnelInstrumentation.js.map +1 -0
- package/build/instrumentation/performance/constants.d.ts +151 -0
- package/build/instrumentation/performance/constants.d.ts.map +1 -0
- package/build/instrumentation/performance/constants.js +158 -0
- package/build/instrumentation/performance/constants.js.map +1 -0
- package/build/instrumentation/performance/performance-tester.d.ts +55 -0
- package/build/instrumentation/performance/performance-tester.d.ts.map +1 -0
- package/build/instrumentation/performance/performance-tester.js +403 -0
- package/build/instrumentation/performance/performance-tester.js.map +1 -0
- package/build/launcher.d.ts +49 -0
- package/build/launcher.d.ts.map +1 -0
- package/build/launcher.js +1077 -0
- package/build/launcher.js.map +1 -0
- package/build/log4jsAppender.d.ts +2 -0
- package/build/log4jsAppender.d.ts.map +1 -0
- package/build/log4jsAppender.js +20 -0
- package/build/log4jsAppender.js.map +1 -0
- package/build/logPatcher.d.ts +13 -0
- package/build/logPatcher.d.ts.map +1 -0
- package/build/logPatcher.js +39 -0
- package/build/logPatcher.js.map +1 -0
- package/build/logReportingAPI.d.ts +12 -0
- package/build/logReportingAPI.d.ts.map +1 -0
- package/build/logReportingAPI.js +57 -0
- package/build/logReportingAPI.js.map +1 -0
- package/build/reporter.d.ts +40 -0
- package/build/reporter.d.ts.map +1 -0
- package/build/reporter.js +254 -0
- package/build/reporter.js.map +1 -0
- package/build/request-handler.d.ts +19 -0
- package/build/request-handler.d.ts.map +1 -0
- package/build/request-handler.js +78 -0
- package/build/request-handler.js.map +1 -0
- package/build/scripts/accessibility-scripts.d.ts +26 -0
- package/build/scripts/accessibility-scripts.d.ts.map +1 -0
- package/build/scripts/accessibility-scripts.js +91 -0
- package/build/scripts/accessibility-scripts.js.map +1 -0
- package/build/service.d.ts +68 -0
- package/build/service.d.ts.map +1 -0
- package/build/service.js +740 -0
- package/build/service.js.map +1 -0
- package/build/testHub/utils.d.ts +10 -0
- package/build/testHub/utils.d.ts.map +1 -0
- package/build/testHub/utils.js +67 -0
- package/build/testHub/utils.js.map +1 -0
- package/build/testOps/featureStats.d.ts +45 -0
- package/build/testOps/featureStats.d.ts.map +1 -0
- package/build/testOps/featureStats.js +117 -0
- package/build/testOps/featureStats.js.map +1 -0
- package/build/testOps/featureUsage.d.ts +22 -0
- package/build/testOps/featureUsage.d.ts.map +1 -0
- package/build/testOps/featureUsage.js +48 -0
- package/build/testOps/featureUsage.js.map +1 -0
- package/build/testOps/listener.d.ts +40 -0
- package/build/testOps/listener.d.ts.map +1 -0
- package/build/testOps/listener.js +269 -0
- package/build/testOps/listener.js.map +1 -0
- package/build/testOps/requestUtils.d.ts +4 -0
- package/build/testOps/requestUtils.d.ts.map +1 -0
- package/build/testOps/requestUtils.js +41 -0
- package/build/testOps/requestUtils.js.map +1 -0
- package/build/testOps/testOpsConfig.d.ts +11 -0
- package/build/testOps/testOpsConfig.d.ts.map +1 -0
- package/build/testOps/testOpsConfig.js +20 -0
- package/build/testOps/testOpsConfig.js.map +1 -0
- package/build/testOps/usageStats.d.ts +404 -0
- package/build/testOps/usageStats.d.ts.map +1 -0
- package/build/testOps/usageStats.js +115 -0
- package/build/testOps/usageStats.js.map +1 -0
- package/build/testorchestration/apply-orchestration.d.ts +7 -0
- package/build/testorchestration/apply-orchestration.d.ts.map +1 -0
- package/build/testorchestration/apply-orchestration.js +43 -0
- package/build/testorchestration/apply-orchestration.js.map +1 -0
- package/build/testorchestration/helpers.d.ts +20 -0
- package/build/testorchestration/helpers.d.ts.map +1 -0
- package/build/testorchestration/helpers.js +413 -0
- package/build/testorchestration/helpers.js.map +1 -0
- package/build/testorchestration/request-utils.d.ts +23 -0
- package/build/testorchestration/request-utils.d.ts.map +1 -0
- package/build/testorchestration/request-utils.js +82 -0
- package/build/testorchestration/request-utils.js.map +1 -0
- package/build/testorchestration/test-ordering-server.d.ts +33 -0
- package/build/testorchestration/test-ordering-server.d.ts.map +1 -0
- package/build/testorchestration/test-ordering-server.js +169 -0
- package/build/testorchestration/test-ordering-server.js.map +1 -0
- package/build/testorchestration/testorcherstrationhandler.d.ts +50 -0
- package/build/testorchestration/testorcherstrationhandler.d.ts.map +1 -0
- package/build/testorchestration/testorcherstrationhandler.js +134 -0
- package/build/testorchestration/testorcherstrationhandler.js.map +1 -0
- package/build/testorchestration/testorcherstrationutils.d.ts +86 -0
- package/build/testorchestration/testorcherstrationutils.d.ts.map +1 -0
- package/build/testorchestration/testorcherstrationutils.js +380 -0
- package/build/testorchestration/testorcherstrationutils.js.map +1 -0
- package/build/types.d.ts +413 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/util.d.ts +241 -0
- package/build/util.d.ts.map +1 -0
- package/build/util.js +1665 -0
- package/build/util.js.map +1 -0
- package/package.json +96 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages-accessibility.proto +71 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages-ai.proto +48 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages-observability.proto +39 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages-percy.proto +10 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages-testhub.proto +10 -0
- package/src/proto/browserstack/sdk/v1/sdk-messages.proto +276 -0
- package/src/proto/browserstack/sdk/v1/sdk.proto +41 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PerformanceObserver } from 'node:perf_hooks';
|
|
2
|
+
type PerformanceDetails = {
|
|
3
|
+
success?: true;
|
|
4
|
+
failure?: string;
|
|
5
|
+
testName?: string;
|
|
6
|
+
worker?: string | number;
|
|
7
|
+
clientWorkerId?: string;
|
|
8
|
+
command?: string;
|
|
9
|
+
hookType?: string;
|
|
10
|
+
platform?: string | number;
|
|
11
|
+
};
|
|
12
|
+
export default class PerformanceTester {
|
|
13
|
+
static _observer: PerformanceObserver;
|
|
14
|
+
static _csvWriter: any;
|
|
15
|
+
private static _events;
|
|
16
|
+
private static _measuredEvents;
|
|
17
|
+
private static _hasStoppedGeneration;
|
|
18
|
+
private static _stopGenerateCallCount;
|
|
19
|
+
static started: boolean;
|
|
20
|
+
static details: {
|
|
21
|
+
[key: string]: PerformanceDetails;
|
|
22
|
+
};
|
|
23
|
+
static eventsMap: {
|
|
24
|
+
[key: string]: number;
|
|
25
|
+
};
|
|
26
|
+
static browser?: WebdriverIO.Browser;
|
|
27
|
+
static scenarioThatRan: string[];
|
|
28
|
+
static jsonReportDirName: string;
|
|
29
|
+
static jsonReportDirPath: string;
|
|
30
|
+
static jsonReportFileName: string;
|
|
31
|
+
static startMonitoring(csvName?: string): void;
|
|
32
|
+
static calculateTimes(methods: string[]): number;
|
|
33
|
+
static stopAndGenerate(filename?: string): Promise<void>;
|
|
34
|
+
static generateReport(entries: PerformanceEntry[]): string;
|
|
35
|
+
static generateCSV(entries: PerformanceEntry[]): void;
|
|
36
|
+
static Measure(label: string, details?: PerformanceDetails): (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
37
|
+
static measureWrapper(name: string, fn: Function, details?: PerformanceDetails): (...args: any[]) => any;
|
|
38
|
+
static isEnabled(): boolean;
|
|
39
|
+
static measure(label: string, fn: Function, details?: {}, args?: IArguments, thisArg?: any): any;
|
|
40
|
+
static start(event: string): void;
|
|
41
|
+
static end(event: string, success?: boolean, failure?: string | unknown, details?: {}): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get client worker ID in format "threadId-processId".
|
|
44
|
+
* This method provides a consistent identifier across the SDK for tracking
|
|
45
|
+
* worker-specific events and performance metrics.
|
|
46
|
+
*
|
|
47
|
+
* @returns Worker ID string in format "threadId-processId"
|
|
48
|
+
*/
|
|
49
|
+
static getClientWorkerId(): string;
|
|
50
|
+
static getProcessId(): string;
|
|
51
|
+
static sleep: (ms?: number) => Promise<unknown>;
|
|
52
|
+
static uploadEventsData(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=performance-tester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-tester.d.ts","sourceRoot":"","sources":["../../../src/instrumentation/performance/performance-tester.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AA0BlE,KAAK,kBAAkB,GAAG;IACtB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG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EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAE,kBAAuB,IAO7D,GAAG,MAAM,GAAG,EAAE;IAQnC,MAAM,CAAC,SAAS;IAIhB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,KAAK,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,OAAO,GAAE,GAAU;IA6FhG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM;IAO1B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,UAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,KAAK;IAWlF;;;;;;OAMG;IACH,MAAM,CAAC,iBAAiB,IAAI,MAAM;IAIlC,MAAM,CAAC,YAAY;IAInB,MAAM,CAAC,KAAK,GAAI,WAAQ,sBAAsD;WAEjE,gBAAgB;CA4GhC"}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { createObjectCsvWriter } from 'csv-writer';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fsPromise from 'node:fs/promises';
|
|
4
|
+
import { performance, PerformanceObserver } from 'node:perf_hooks';
|
|
5
|
+
import util from 'node:util';
|
|
6
|
+
import worker from 'node:worker_threads';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { arch, hostname, platform, type, version } from 'node:os';
|
|
9
|
+
import got from 'got';
|
|
10
|
+
import { BStackLogger } from '../../bstackLogger.js';
|
|
11
|
+
import { PERF_MEASUREMENT_ENV } from '../../constants.js';
|
|
12
|
+
import APIUtils from '../../cli/apiUtils.js';
|
|
13
|
+
import { CLIUtils } from '../../cli/cliUtils.js';
|
|
14
|
+
import { EVENTS } from './constants.js';
|
|
15
|
+
// Telemetry must never throw into business logic. Node 18's perf_hooks rejects
|
|
16
|
+
// negative timestamps (e.g. performance.now() under faked timers, or any other
|
|
17
|
+
// edge) with ERR_PERFORMANCE_INVALID_TIMESTAMP; Node 20+ tolerates them. Wrapping
|
|
18
|
+
// mark/measure keeps an instrumentation failure from breaking a caller's hook
|
|
19
|
+
// (e.g. a service before()), and is a no-op on the happy path.
|
|
20
|
+
function safeMark(markName) {
|
|
21
|
+
try {
|
|
22
|
+
performance.mark(markName);
|
|
23
|
+
}
|
|
24
|
+
catch { /* instrumentation must not throw */ }
|
|
25
|
+
}
|
|
26
|
+
function safeMeasure(measureName, start, end) {
|
|
27
|
+
try {
|
|
28
|
+
performance.measure(measureName, start, end);
|
|
29
|
+
}
|
|
30
|
+
catch { /* instrumentation must not throw */ }
|
|
31
|
+
}
|
|
32
|
+
export default class PerformanceTester {
|
|
33
|
+
static _observer;
|
|
34
|
+
static _csvWriter;
|
|
35
|
+
static _events = [];
|
|
36
|
+
static _measuredEvents = [];
|
|
37
|
+
static _hasStoppedGeneration = false;
|
|
38
|
+
static _stopGenerateCallCount = 0;
|
|
39
|
+
static started = false;
|
|
40
|
+
static details = {};
|
|
41
|
+
static eventsMap = {};
|
|
42
|
+
static browser;
|
|
43
|
+
static scenarioThatRan;
|
|
44
|
+
static jsonReportDirName = 'performance-report';
|
|
45
|
+
static jsonReportDirPath = path.join(process.cwd(), 'logs', this.jsonReportDirName);
|
|
46
|
+
static jsonReportFileName = `${this.jsonReportDirPath}/performance-report-${PerformanceTester.getProcessId()}.json`;
|
|
47
|
+
static startMonitoring(csvName = 'performance-report.csv') {
|
|
48
|
+
// Create performance-report dir if not exists already
|
|
49
|
+
if (!fs.existsSync(this.jsonReportDirPath)) {
|
|
50
|
+
fs.mkdirSync(this.jsonReportDirPath, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
this._observer = new PerformanceObserver(list => {
|
|
53
|
+
list.getEntries()
|
|
54
|
+
.filter((entry) => entry.entryType === 'measure')
|
|
55
|
+
.forEach(entry => {
|
|
56
|
+
let finalEntry = entry;
|
|
57
|
+
finalEntry = entry.toJSON();
|
|
58
|
+
try {
|
|
59
|
+
if (typeof finalEntry.startTime === 'number' && typeof performance.timeOrigin === 'number') {
|
|
60
|
+
finalEntry.startTime = performance.timeOrigin + finalEntry.startTime;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
BStackLogger.debug(`Error converting startTime to epoch: ${util.format(e)}`);
|
|
65
|
+
}
|
|
66
|
+
if (this.details[entry.name]) {
|
|
67
|
+
finalEntry = Object.assign(finalEntry, this.details[entry.name]);
|
|
68
|
+
}
|
|
69
|
+
delete this.details[entry.name];
|
|
70
|
+
this._measuredEvents.push(finalEntry);
|
|
71
|
+
});
|
|
72
|
+
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
73
|
+
list.getEntries().forEach((entry) => this._events.push(entry));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const entryTypes = ['measure'];
|
|
77
|
+
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
78
|
+
entryTypes.push('function');
|
|
79
|
+
}
|
|
80
|
+
this._observer.observe({ buffered: true, entryTypes: entryTypes });
|
|
81
|
+
this.started = true;
|
|
82
|
+
if (process.env[PERF_MEASUREMENT_ENV]) {
|
|
83
|
+
this._csvWriter = createObjectCsvWriter({
|
|
84
|
+
path: csvName,
|
|
85
|
+
header: [
|
|
86
|
+
{ id: 'name', title: 'Function Name' },
|
|
87
|
+
{ id: 'time', title: 'Execution Time (ms)' }
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
static calculateTimes(methods) {
|
|
93
|
+
const times = {};
|
|
94
|
+
this._events.map((entry) => {
|
|
95
|
+
if (!times[entry.name]) {
|
|
96
|
+
times[entry.name] = 0;
|
|
97
|
+
}
|
|
98
|
+
times[entry.name] += entry.duration;
|
|
99
|
+
});
|
|
100
|
+
const timeTaken = methods.reduce((a, c) => {
|
|
101
|
+
return times[c] + (a || 0);
|
|
102
|
+
}, 0);
|
|
103
|
+
BStackLogger.debug(`Time for ${methods} is ${timeTaken}`);
|
|
104
|
+
return timeTaken;
|
|
105
|
+
}
|
|
106
|
+
static async stopAndGenerate(filename = 'performance-own.html') {
|
|
107
|
+
if (!this.started) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const eventsJson = JSON.stringify(this._measuredEvents);
|
|
112
|
+
// remove enclosing array and add a trailing comma so that we
|
|
113
|
+
// dont need to both read and then write the file, we can use append instead
|
|
114
|
+
const finalJSONStr = eventsJson.slice(1, -1) + ',';
|
|
115
|
+
await fsPromise.appendFile(this.jsonReportFileName, finalJSONStr);
|
|
116
|
+
}
|
|
117
|
+
catch (er) {
|
|
118
|
+
BStackLogger.debug(`Failed to write events of the worker to ${this.jsonReportFileName}: ${util.format(er)}`);
|
|
119
|
+
}
|
|
120
|
+
this._observer.disconnect();
|
|
121
|
+
if (!process.env[PERF_MEASUREMENT_ENV]) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.started = false;
|
|
125
|
+
// Generate CSV and HTML reports using directly collected events
|
|
126
|
+
this.generateCSV(this._events);
|
|
127
|
+
const content = this.generateReport(this._events);
|
|
128
|
+
const dir = path.join(process.cwd(), filename);
|
|
129
|
+
try {
|
|
130
|
+
await fsPromise.writeFile(dir, content);
|
|
131
|
+
BStackLogger.info(`Performance report is at ${path}`);
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
BStackLogger.error(`Error in writing html ${util.format(err)}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
static generateReport(entries) {
|
|
138
|
+
let html = '<!DOCTYPE html><html><head><title>Performance Report</title></head><body>';
|
|
139
|
+
html += '<h1>Performance Report</h1>';
|
|
140
|
+
html += '<table><thead><tr><th>Function Name</th><th>Duration (ms)</th></tr></thead><tbody>';
|
|
141
|
+
entries.forEach((entry) => {
|
|
142
|
+
html += `<tr><td>${entry.name}</td><td>${entry.duration}</td></tr>`;
|
|
143
|
+
});
|
|
144
|
+
html += '</tbody></table></body></html>';
|
|
145
|
+
return html;
|
|
146
|
+
}
|
|
147
|
+
static generateCSV(entries) {
|
|
148
|
+
const times = {};
|
|
149
|
+
entries.map((entry) => {
|
|
150
|
+
if (!times[entry.name]) {
|
|
151
|
+
times[entry.name] = 0;
|
|
152
|
+
}
|
|
153
|
+
times[entry.name] += entry.duration;
|
|
154
|
+
return {
|
|
155
|
+
name: entry.name,
|
|
156
|
+
time: entry.duration
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
const dat = Object.entries(times).map(([key, value]) => {
|
|
160
|
+
return {
|
|
161
|
+
name: key,
|
|
162
|
+
time: value
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
this._csvWriter.writeRecords(dat)
|
|
166
|
+
.then(() => BStackLogger.info('Performance CSV report generated successfully'))
|
|
167
|
+
.catch((error) => console.error(error));
|
|
168
|
+
}
|
|
169
|
+
static Measure(label, details = {}) {
|
|
170
|
+
const self = this;
|
|
171
|
+
return (target, key, descriptor) => {
|
|
172
|
+
const originalMethod = descriptor.value;
|
|
173
|
+
if (descriptor.value) {
|
|
174
|
+
descriptor.value = function () {
|
|
175
|
+
return PerformanceTester.measure.apply(self, [label, originalMethod, { methodName: key.toString(), ...details }, arguments, this]);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
static measureWrapper(name, fn, details = {}) {
|
|
181
|
+
const self = this;
|
|
182
|
+
details.worker = PerformanceTester.getProcessId();
|
|
183
|
+
details.testName = PerformanceTester.scenarioThatRan?.pop();
|
|
184
|
+
details.platform = PerformanceTester.browser?.sessionId;
|
|
185
|
+
return function (...args) {
|
|
186
|
+
const methodArgs = [name, fn, details, args];
|
|
187
|
+
return self.measure.apply(self, methodArgs);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
static isEnabled() {
|
|
191
|
+
return !(process.env.BROWSERSTACK_SDK_INSTRUMENTATION === 'false');
|
|
192
|
+
}
|
|
193
|
+
static measure(label, fn, details = {}, args, thisArg = null) {
|
|
194
|
+
if (!this.started || !this.isEnabled()) {
|
|
195
|
+
return fn.apply(thisArg, args);
|
|
196
|
+
}
|
|
197
|
+
// Generate unique mark names for this specific call to avoid timing conflicts
|
|
198
|
+
const uniqueId = `${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
199
|
+
const startMark = `${label}-start-${uniqueId}`;
|
|
200
|
+
const endMark = `${label}-end-${uniqueId}`;
|
|
201
|
+
// Create the start mark with unique ID
|
|
202
|
+
safeMark(startMark);
|
|
203
|
+
// Store details with measurement context
|
|
204
|
+
const detailsWithContext = {
|
|
205
|
+
...details,
|
|
206
|
+
measurementId: uniqueId
|
|
207
|
+
};
|
|
208
|
+
try {
|
|
209
|
+
const returnVal = fn.apply(thisArg, args);
|
|
210
|
+
if (returnVal instanceof Promise) {
|
|
211
|
+
return new Promise((resolve, reject) => {
|
|
212
|
+
returnVal
|
|
213
|
+
.then(v => {
|
|
214
|
+
// Use specific marks for this call
|
|
215
|
+
safeMark(endMark);
|
|
216
|
+
safeMeasure(label, startMark, endMark);
|
|
217
|
+
this.details[label] = Object.assign({
|
|
218
|
+
success: true,
|
|
219
|
+
failure: undefined
|
|
220
|
+
}, Object.assign(Object.assign({
|
|
221
|
+
clientWorkerId: PerformanceTester.getClientWorkerId(),
|
|
222
|
+
worker: PerformanceTester.getProcessId(),
|
|
223
|
+
platform: PerformanceTester.browser?.sessionId,
|
|
224
|
+
testName: PerformanceTester.scenarioThatRan?.pop()
|
|
225
|
+
}, detailsWithContext), this.details[label] || {}));
|
|
226
|
+
resolve(v);
|
|
227
|
+
}).catch(e => {
|
|
228
|
+
safeMark(endMark);
|
|
229
|
+
safeMeasure(label, startMark, endMark);
|
|
230
|
+
this.details[label] = Object.assign({
|
|
231
|
+
success: false,
|
|
232
|
+
failure: util.format(e)
|
|
233
|
+
}, Object.assign(Object.assign({
|
|
234
|
+
clientWorkerId: PerformanceTester.getClientWorkerId(),
|
|
235
|
+
worker: PerformanceTester.getProcessId(),
|
|
236
|
+
platform: PerformanceTester.browser?.sessionId,
|
|
237
|
+
testName: PerformanceTester.scenarioThatRan?.pop()
|
|
238
|
+
}, detailsWithContext), this.details[label] || {}));
|
|
239
|
+
reject(e);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
// Synchronous execution
|
|
244
|
+
safeMark(endMark);
|
|
245
|
+
safeMeasure(label, startMark, endMark);
|
|
246
|
+
this.details[label] = Object.assign({
|
|
247
|
+
success: true,
|
|
248
|
+
failure: undefined
|
|
249
|
+
}, Object.assign(Object.assign({
|
|
250
|
+
clientWorkerId: PerformanceTester.getClientWorkerId(),
|
|
251
|
+
worker: PerformanceTester.getProcessId(),
|
|
252
|
+
platform: PerformanceTester.browser?.sessionId,
|
|
253
|
+
testName: PerformanceTester.scenarioThatRan?.pop()
|
|
254
|
+
}, detailsWithContext), this.details[label] || {}));
|
|
255
|
+
return returnVal;
|
|
256
|
+
}
|
|
257
|
+
catch (er) {
|
|
258
|
+
safeMark(endMark);
|
|
259
|
+
safeMeasure(label, startMark, endMark);
|
|
260
|
+
this.details[label] = Object.assign({
|
|
261
|
+
success: false,
|
|
262
|
+
failure: util.format(er)
|
|
263
|
+
}, Object.assign(Object.assign({
|
|
264
|
+
clientWorkerId: PerformanceTester.getClientWorkerId(),
|
|
265
|
+
worker: PerformanceTester.getProcessId(),
|
|
266
|
+
platform: PerformanceTester.browser?.sessionId,
|
|
267
|
+
testName: PerformanceTester.scenarioThatRan?.pop()
|
|
268
|
+
}, detailsWithContext), this.details[label] || {}));
|
|
269
|
+
throw er;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
static start(event) {
|
|
273
|
+
const finalEvent = event + '-start';
|
|
274
|
+
if (this.eventsMap[finalEvent]) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
safeMark(finalEvent);
|
|
278
|
+
this.eventsMap[finalEvent] = 1;
|
|
279
|
+
}
|
|
280
|
+
static end(event, success = true, failure, details = {}) {
|
|
281
|
+
safeMark(event + '-end');
|
|
282
|
+
safeMeasure(event, event + '-start', event + '-end');
|
|
283
|
+
this.details[event] = Object.assign({ success, failure: util.format(failure) }, Object.assign(Object.assign({
|
|
284
|
+
clientWorkerId: PerformanceTester.getClientWorkerId(),
|
|
285
|
+
worker: PerformanceTester.getProcessId(),
|
|
286
|
+
platform: PerformanceTester.browser?.sessionId,
|
|
287
|
+
testName: PerformanceTester.scenarioThatRan?.pop()
|
|
288
|
+
}, details), this.details[event] || {}));
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get client worker ID in format "threadId-processId".
|
|
292
|
+
* This method provides a consistent identifier across the SDK for tracking
|
|
293
|
+
* worker-specific events and performance metrics.
|
|
294
|
+
*
|
|
295
|
+
* @returns Worker ID string in format "threadId-processId"
|
|
296
|
+
*/
|
|
297
|
+
static getClientWorkerId() {
|
|
298
|
+
return CLIUtils.getClientWorkerId();
|
|
299
|
+
}
|
|
300
|
+
static getProcessId() {
|
|
301
|
+
return `${process.pid}-${worker.threadId}`;
|
|
302
|
+
}
|
|
303
|
+
static sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
304
|
+
static async uploadEventsData() {
|
|
305
|
+
// Track overall key metrics operation
|
|
306
|
+
this.start(EVENTS.SDK_SEND_KEY_METRICS);
|
|
307
|
+
try {
|
|
308
|
+
const workerId = `${process.pid}`;
|
|
309
|
+
BStackLogger.debug(`[Performance Upload] Starting upload for worker ${workerId}`);
|
|
310
|
+
// Track preparation phase (collection and deduplication)
|
|
311
|
+
this.start(EVENTS.SDK_KEY_METRICS_PREPARATION);
|
|
312
|
+
// Collect all measures from performance report files and in-memory events
|
|
313
|
+
let measures = [];
|
|
314
|
+
if (await fsPromise.access(this.jsonReportDirPath).then(() => true).catch(() => false)) {
|
|
315
|
+
const files = (await fsPromise.readdir(this.jsonReportDirPath)).map(file => path.resolve(this.jsonReportDirPath, file));
|
|
316
|
+
measures = (await Promise.all(files.map((file) => fsPromise.readFile(file, 'utf-8')))).map(el => `[${el.slice(0, -1)}]`).map(el => JSON.parse(el)).flat();
|
|
317
|
+
}
|
|
318
|
+
BStackLogger.debug(`[Performance Upload] Total events from files: ${measures.length}`);
|
|
319
|
+
if (this._measuredEvents.length > 0) {
|
|
320
|
+
BStackLogger.debug(`[Performance Upload] Adding ${this._measuredEvents.length} in-memory events`);
|
|
321
|
+
measures = measures.concat(this._measuredEvents);
|
|
322
|
+
}
|
|
323
|
+
const ensureEpochTimes = (arr) => {
|
|
324
|
+
const now = Date.now();
|
|
325
|
+
const cutoff = 1e12; // ~year 2001, ms epoch
|
|
326
|
+
const timeOrigin = (typeof performance !== 'undefined' && typeof performance.timeOrigin === 'number')
|
|
327
|
+
? performance.timeOrigin
|
|
328
|
+
: (now - process.uptime() * 1000);
|
|
329
|
+
return arr.map(entry => {
|
|
330
|
+
if (typeof entry.startTime === 'number' && entry.startTime < cutoff) {
|
|
331
|
+
entry.startTime = timeOrigin + entry.startTime;
|
|
332
|
+
}
|
|
333
|
+
return entry;
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
measures = ensureEpochTimes(measures);
|
|
337
|
+
const date = new Date();
|
|
338
|
+
// yyyy-MM-dd'T'HH:mm:ss.SSSSSS Z
|
|
339
|
+
const options = {
|
|
340
|
+
timeZone: 'UTC',
|
|
341
|
+
year: 'numeric',
|
|
342
|
+
month: '2-digit',
|
|
343
|
+
day: '2-digit',
|
|
344
|
+
hour: '2-digit',
|
|
345
|
+
minute: '2-digit',
|
|
346
|
+
second: '2-digit',
|
|
347
|
+
fractionalSecondDigits: 3, // To include microseconds
|
|
348
|
+
hour12: false
|
|
349
|
+
};
|
|
350
|
+
// Format the date and replace the default separator for time zone
|
|
351
|
+
const formattedDate = new Intl.DateTimeFormat('en-GB', options)
|
|
352
|
+
.formatToParts(date)
|
|
353
|
+
.map(({ type, value }) => type === 'timeZoneName' ? 'Z' : value)
|
|
354
|
+
.join('')
|
|
355
|
+
.replace(',', 'T');
|
|
356
|
+
this.end(EVENTS.SDK_KEY_METRICS_PREPARATION, true);
|
|
357
|
+
const payload = {
|
|
358
|
+
event_type: 'sdk_events',
|
|
359
|
+
data: {
|
|
360
|
+
testhub_uuid: process.env.PERF_TESTHUB_UUID || process.env.PERF_SDK_RUN_ID,
|
|
361
|
+
created_day: formattedDate,
|
|
362
|
+
event_name: 'SDKFeaturePerformance',
|
|
363
|
+
user_data: process.env.PERF_USER_NAME,
|
|
364
|
+
host_info: JSON.stringify({
|
|
365
|
+
hostname: hostname(),
|
|
366
|
+
platform: platform(),
|
|
367
|
+
type: type(),
|
|
368
|
+
version: version(),
|
|
369
|
+
arch: arch()
|
|
370
|
+
}),
|
|
371
|
+
event_json: { measures: measures, sdkRunId: process.env.PERF_SDK_RUN_ID }
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const result = await got.post(`${APIUtils.EDS_URL}/send_sdk_events`, {
|
|
375
|
+
headers: {
|
|
376
|
+
'content-type': 'application/json'
|
|
377
|
+
}, json: payload
|
|
378
|
+
});
|
|
379
|
+
BStackLogger.debug(`[Performance Upload] Successfully uploaded to EDS: ${util.format(result.body)}`);
|
|
380
|
+
this.end(EVENTS.SDK_KEY_METRICS_UPLOAD, true);
|
|
381
|
+
this.end(EVENTS.SDK_SEND_KEY_METRICS, true);
|
|
382
|
+
}
|
|
383
|
+
catch (er) {
|
|
384
|
+
BStackLogger.debug(`[Performance Upload] Failed to upload events: ${util.format(er)}`);
|
|
385
|
+
this.end(EVENTS.SDK_KEY_METRICS_UPLOAD, false, er);
|
|
386
|
+
this.end(EVENTS.SDK_KEY_METRICS_PREPARATION, false, er);
|
|
387
|
+
this.end(EVENTS.SDK_SEND_KEY_METRICS, false, er);
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
if (await fsPromise.access(this.jsonReportDirPath).then(() => true, () => false)) {
|
|
391
|
+
const files = await fsPromise.readdir(this.jsonReportDirPath);
|
|
392
|
+
for (const file of files) {
|
|
393
|
+
await fsPromise.unlink(path.join(this.jsonReportDirPath, file));
|
|
394
|
+
}
|
|
395
|
+
BStackLogger.debug(`[Performance Upload] Cleaned up ${files.length} temporary report files`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
catch (er) {
|
|
399
|
+
BStackLogger.debug(`[Performance Upload] Failed to delete temporary files: ${util.format(er)}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=performance-tester.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-tester.js","sourceRoot":"","sources":["../../../src/instrumentation/performance/performance-tester.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjE,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,+EAA+E;AAC/E,+EAA+E;AAC/E,kFAAkF;AAClF,8EAA8E;AAC9E,+DAA+D;AAC/D,SAAS,QAAQ,CAAC,QAAgB;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AE,CAAC,CAAA;YACvD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QACpD,CAAC;QAED,IAAI,CAAC;YACD,IAAI,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/E,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;gBAE7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACvB,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAA;gBACnE,CAAC;gBAED,YAAY,CAAC,KAAK,CAAC,mCAAmC,KAAK,CAAC,MAAM,yBAAyB,CAAC,CAAA;YAChG,CAAC;QACL,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,0DAA0D,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QACnG,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as BrowserstackLocalLauncher from 'browserstack-local';
|
|
2
|
+
import type { Capabilities, Services, Options } from '@wdio/types';
|
|
3
|
+
import type { BrowserstackConfig, App, AppConfig, AppUploadResponse, UserConfig, BrowserstackOptions } from './types.js';
|
|
4
|
+
type BrowserstackLocal = BrowserstackLocalLauncher.Local & {
|
|
5
|
+
pid?: number;
|
|
6
|
+
stop(callback: (err?: Error) => void): void;
|
|
7
|
+
};
|
|
8
|
+
export default class BrowserstackLauncherService implements Services.ServiceInstance {
|
|
9
|
+
private _options;
|
|
10
|
+
private _config;
|
|
11
|
+
browserstackLocal?: BrowserstackLocal;
|
|
12
|
+
private _buildName?;
|
|
13
|
+
private _projectName?;
|
|
14
|
+
private _buildTag?;
|
|
15
|
+
private _buildIdentifier?;
|
|
16
|
+
private _accessibilityAutomation?;
|
|
17
|
+
private _percy?;
|
|
18
|
+
private _percyBestPlatformCaps?;
|
|
19
|
+
private readonly browserStackConfig;
|
|
20
|
+
constructor(_options: BrowserstackConfig & BrowserstackOptions, capabilities: Capabilities.RemoteCapability, _config: Options.Testrunner);
|
|
21
|
+
onWorkerStart(cid: any, caps: any): Promise<void>;
|
|
22
|
+
onPrepare(config: Options.Testrunner, capabilities: Capabilities.RemoteCapabilities): Promise<unknown>;
|
|
23
|
+
onComplete(): Promise<unknown>;
|
|
24
|
+
setupPercy(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner, bsConfig: UserConfig): Promise<void>;
|
|
25
|
+
stopPercy(): Promise<void>;
|
|
26
|
+
_uploadApp(app: App): Promise<AppUploadResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* @param {String | AppConfig} appConfig <string>: should be "app file path" or "app_url" or "custom_id" or "shareable_id".
|
|
29
|
+
* <object>: only "path" and "custom_id" should coexist as multiple properties.
|
|
30
|
+
*/
|
|
31
|
+
_validateApp(appConfig: AppConfig | string): Promise<App>;
|
|
32
|
+
_uploadServiceLogs(): Promise<void>;
|
|
33
|
+
private _removeCliOnlyCapabilityOptions;
|
|
34
|
+
_updateObjectTypeCaps(capabilities?: Capabilities.RemoteCapabilities, capType?: string, value?: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}): void;
|
|
37
|
+
_updateCaps(capabilities?: Capabilities.RemoteCapabilities, capType?: string, value?: string): void;
|
|
38
|
+
_updateBrowserStackPercyConfig(): void;
|
|
39
|
+
_handleBuildIdentifier(capabilities?: Capabilities.RemoteCapabilities): void;
|
|
40
|
+
/**
|
|
41
|
+
* @return {string} if buildName doesn't exist in json file, it will return 1
|
|
42
|
+
* else returns corresponding value in json file (e.g. { "wdio-build": { "identifier" : 2 } } => 2 in this case)
|
|
43
|
+
*/
|
|
44
|
+
_getLocalBuildNumber(): string | null;
|
|
45
|
+
_updateLocalBuildCache(filePath?: string, buildName?: string, buildIdentifier?: number): void;
|
|
46
|
+
_getClientBuildUuid(): string;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=launcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,yBAAyB,MAAM,oBAAoB,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAmDxH,KAAK,iBAAiB,GAAG,yBAAyB,CAAC,KAAK,GAAG;IACvD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAA;CAC9C,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,2BAA4B,YAAW,QAAQ,CAAC,eAAe;IAY5E,OAAO,CAAC,QAAQ;IAEhB,OAAO,CAAC,OAAO;IAbnB,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAC,CAAQ;IAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAQ;IACjC,OAAO,CAAC,wBAAwB,CAAC,CAAuB;IACxD,OAAO,CAAC,MAAM,CAAC,CAAO;IACtB,OAAO,CAAC,sBAAsB,CAAC,CAAkC;IACjE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;g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