@wdio/browserstack-service 8.45.0 → 8.47.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.
Files changed (118) hide show
  1. package/README.md +44 -11
  2. package/build/Percy/Percy-Handler.d.ts.map +1 -1
  3. package/build/Percy/Percy-Handler.js +4 -1
  4. package/build/Percy/Percy.d.ts.map +1 -1
  5. package/build/Percy/Percy.js +2 -1
  6. package/build/accessibility-handler.d.ts +9 -3
  7. package/build/accessibility-handler.d.ts.map +1 -1
  8. package/build/accessibility-handler.js +52 -11
  9. package/build/cleanup.js +3 -3
  10. package/build/cli/apiUtils.d.ts +14 -0
  11. package/build/cli/apiUtils.d.ts.map +1 -0
  12. package/build/cli/apiUtils.js +24 -0
  13. package/build/cli/cliLogger.d.ts +16 -0
  14. package/build/cli/cliLogger.d.ts.map +1 -0
  15. package/build/cli/cliLogger.js +70 -0
  16. package/build/cli/cliUtils.d.ts +46 -0
  17. package/build/cli/cliUtils.d.ts.map +1 -0
  18. package/build/cli/cliUtils.js +430 -0
  19. package/build/cli/eventDispatcher.d.ts +28 -0
  20. package/build/cli/eventDispatcher.d.ts.map +1 -0
  21. package/build/cli/eventDispatcher.js +48 -0
  22. package/build/cli/frameworks/automationFramework.d.ts +89 -0
  23. package/build/cli/frameworks/automationFramework.d.ts.map +1 -0
  24. package/build/cli/frameworks/automationFramework.js +131 -0
  25. package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts +18 -0
  26. package/build/cli/frameworks/constants/automationFrameworkConstants.d.ts.map +1 -0
  27. package/build/cli/frameworks/constants/automationFrameworkConstants.js +17 -0
  28. package/build/cli/frameworks/constants/testFrameworkConstants.d.ts +43 -0
  29. package/build/cli/frameworks/constants/testFrameworkConstants.d.ts.map +1 -0
  30. package/build/cli/frameworks/constants/testFrameworkConstants.js +42 -0
  31. package/build/cli/frameworks/testFramework.d.ts +89 -0
  32. package/build/cli/frameworks/testFramework.d.ts.map +1 -0
  33. package/build/cli/frameworks/testFramework.js +125 -0
  34. package/build/cli/frameworks/wdioAutomationFramework.d.ts +28 -0
  35. package/build/cli/frameworks/wdioAutomationFramework.d.ts.map +1 -0
  36. package/build/cli/frameworks/wdioAutomationFramework.js +66 -0
  37. package/build/cli/frameworks/wdioMochaTestFramework.d.ts +82 -0
  38. package/build/cli/frameworks/wdioMochaTestFramework.d.ts.map +1 -0
  39. package/build/cli/frameworks/wdioMochaTestFramework.js +319 -0
  40. package/build/cli/grpcClient.d.ts +70 -0
  41. package/build/cli/grpcClient.d.ts.map +1 -0
  42. package/build/cli/grpcClient.js +419 -0
  43. package/build/cli/index.d.ts +148 -0
  44. package/build/cli/index.d.ts.map +1 -0
  45. package/build/cli/index.js +415 -0
  46. package/build/cli/instances/automationFrameworkInstance.d.ts +33 -0
  47. package/build/cli/instances/automationFrameworkInstance.d.ts.map +1 -0
  48. package/build/cli/instances/automationFrameworkInstance.js +44 -0
  49. package/build/cli/instances/testFrameworkInstance.d.ts +62 -0
  50. package/build/cli/instances/testFrameworkInstance.d.ts.map +1 -0
  51. package/build/cli/instances/testFrameworkInstance.js +96 -0
  52. package/build/cli/instances/trackedContext.d.ts +32 -0
  53. package/build/cli/instances/trackedContext.d.ts.map +1 -0
  54. package/build/cli/instances/trackedContext.js +47 -0
  55. package/build/cli/instances/trackedInstance.d.ts +40 -0
  56. package/build/cli/instances/trackedInstance.d.ts.map +1 -0
  57. package/build/cli/instances/trackedInstance.js +63 -0
  58. package/build/cli/modules/accessibilityModule.d.ts +33 -0
  59. package/build/cli/modules/accessibilityModule.d.ts.map +1 -0
  60. package/build/cli/modules/accessibilityModule.js +347 -0
  61. package/build/cli/modules/automateModule.d.ts +26 -0
  62. package/build/cli/modules/automateModule.d.ts.map +1 -0
  63. package/build/cli/modules/automateModule.js +222 -0
  64. package/build/cli/modules/baseModule.d.ts +33 -0
  65. package/build/cli/modules/baseModule.d.ts.map +1 -0
  66. package/build/cli/modules/baseModule.js +51 -0
  67. package/build/cli/modules/observabilityModule.d.ts +22 -0
  68. package/build/cli/modules/observabilityModule.d.ts.map +1 -0
  69. package/build/cli/modules/observabilityModule.js +45 -0
  70. package/build/cli/modules/percyModule.d.ts +19 -0
  71. package/build/cli/modules/percyModule.d.ts.map +1 -0
  72. package/build/cli/modules/percyModule.js +77 -0
  73. package/build/cli/modules/testHubModule.d.ts +30 -0
  74. package/build/cli/modules/testHubModule.d.ts.map +1 -0
  75. package/build/cli/modules/testHubModule.js +232 -0
  76. package/build/cli/modules/webdriverIOModule.d.ts +29 -0
  77. package/build/cli/modules/webdriverIOModule.d.ts.map +1 -0
  78. package/build/cli/modules/webdriverIOModule.js +128 -0
  79. package/build/cli/states/automationFrameworkState.d.ts +65 -0
  80. package/build/cli/states/automationFrameworkState.d.ts.map +1 -0
  81. package/build/cli/states/automationFrameworkState.js +61 -0
  82. package/build/cli/states/hookState.d.ts +45 -0
  83. package/build/cli/states/hookState.d.ts.map +1 -0
  84. package/build/cli/states/hookState.js +43 -0
  85. package/build/cli/states/testFrameworkState.d.ts +125 -0
  86. package/build/cli/states/testFrameworkState.d.ts.map +1 -0
  87. package/build/cli/states/testFrameworkState.js +115 -0
  88. package/build/constants.d.ts +13 -0
  89. package/build/constants.d.ts.map +1 -1
  90. package/build/constants.js +21 -1
  91. package/build/crash-reporter.d.ts.map +1 -1
  92. package/build/crash-reporter.js +4 -3
  93. package/build/exitHandler.d.ts.map +1 -1
  94. package/build/exitHandler.js +47 -5
  95. package/build/insights-handler.d.ts +8 -0
  96. package/build/insights-handler.d.ts.map +1 -1
  97. package/build/insights-handler.js +57 -1
  98. package/build/instrumentation/funnelInstrumentation.d.ts.map +1 -1
  99. package/build/instrumentation/funnelInstrumentation.js +5 -4
  100. package/build/instrumentation/performance/constants.d.ts +8 -0
  101. package/build/instrumentation/performance/constants.d.ts.map +1 -1
  102. package/build/instrumentation/performance/constants.js +9 -1
  103. package/build/instrumentation/performance/performance-tester.d.ts.map +1 -1
  104. package/build/instrumentation/performance/performance-tester.js +5 -3
  105. package/build/launcher.d.ts.map +1 -1
  106. package/build/launcher.js +94 -51
  107. package/build/request-handler.js +1 -1
  108. package/build/service.d.ts +3 -1
  109. package/build/service.d.ts.map +1 -1
  110. package/build/service.js +244 -69
  111. package/build/testOps/requestUtils.js +3 -2
  112. package/build/types.d.ts +36 -3
  113. package/build/types.d.ts.map +1 -1
  114. package/build/util.d.ts +13 -1
  115. package/build/util.d.ts.map +1 -1
  116. package/build/util.js +173 -27
  117. package/package.json +7 -4
  118. package/tsconfig.prod.tsbuildinfo +1 -1
@@ -0,0 +1,131 @@
1
+ import { BStackLogger as logger } from '../cliLogger.js';
2
+ import { eventDispatcher } from '../eventDispatcher.js';
3
+ import { CLIUtils } from '../cliUtils.js';
4
+ import TrackedInstance from '../instances/trackedInstance.js';
5
+ import { AutomationFrameworkConstants } from './constants/automationFrameworkConstants.js';
6
+ /**
7
+ * AutomationFramework - Automation Framework abstract class
8
+ */
9
+ export default class AutomationFramework {
10
+ #automationFrameworkName;
11
+ #automationFrameworkVersion;
12
+ static instances = new Map();
13
+ static KEY_AUTOMATION_SESSIONS = 'automation_sessions';
14
+ static KEY_NON_BROWSERSTACK_AUTOMATION_SESSIONS = 'non_browserstack_automation_sessions';
15
+ /**
16
+ * Constructor for the AutomationFramework
17
+ * @param {string} automationFrameworkName - Name of the automation framework
18
+ * @param {string} automationFrameworkVersion - Version of the automation framework
19
+ */
20
+ constructor(automationFrameworkName, automationFrameworkVersion) {
21
+ this.#automationFrameworkName = automationFrameworkName;
22
+ this.#automationFrameworkVersion = automationFrameworkVersion;
23
+ }
24
+ /**
25
+ * Get the automation framework name
26
+ * @returns {string} The name of the automation framework
27
+ */
28
+ getAutomationFrameworkName() {
29
+ return this.#automationFrameworkName;
30
+ }
31
+ /**
32
+ * Get the automation framework version
33
+ * @returns {string} The version of the automation framework
34
+ */
35
+ getAutomationFrameworkVersion() {
36
+ return this.#automationFrameworkVersion;
37
+ }
38
+ /**
39
+ * Track an event
40
+ * @param {Object}
41
+ * @param {Object}
42
+ * @param {Object}
43
+ * @returns {void}
44
+ */
45
+ async trackEvent(automationFrameworkState, hookState, args = {}) {
46
+ logger.info(`trackEvent: automationFrameworkState=${automationFrameworkState} hookState=${hookState} args=${args}`);
47
+ }
48
+ /**
49
+ *
50
+ * @param {*} instance
51
+ * @param {*} automationFrameworkState
52
+ * @param {*} hookState
53
+ * @param {*} args
54
+ */
55
+ async runHooks(instance, automationFrameworkState, hookState, args = {}) {
56
+ logger.info(`runHooks: automationFrameworkState=${automationFrameworkState} hookState=${hookState}`);
57
+ const hookRegistryKey = CLIUtils.getHookRegistryKey(automationFrameworkState, hookState);
58
+ await eventDispatcher.notifyObserver(hookRegistryKey, args);
59
+ }
60
+ /**
61
+ * Register an observer
62
+ * @returns {void}
63
+ */
64
+ static registerObserver(automationFrameworkState, hookState, callback) {
65
+ eventDispatcher.registerObserver(CLIUtils.getHookRegistryKey(automationFrameworkState, hookState), callback);
66
+ }
67
+ /**
68
+ * Set the tracked instance
69
+ * @param {TrackedInstance} context - The context
70
+ * @param {TrackedInstance} instance - The instance
71
+ * @returns {void}
72
+ */
73
+ static setTrackedInstance(context, instance) {
74
+ logger.debug(`setTrackedInstance: ${context.getId()}`);
75
+ AutomationFramework.instances.set(context.getId(), instance);
76
+ }
77
+ /**
78
+ * Get the tracked instance
79
+ * @returns {TrackedInstance} The tracked instance
80
+ */
81
+ static getTrackedInstance() {
82
+ logger.debug(`getTrackedInstance: ${CLIUtils.getCurrentInstanceName()}`);
83
+ const context = TrackedInstance.createContext(CLIUtils.getCurrentInstanceName());
84
+ return AutomationFramework.instances.get(context.getId());
85
+ }
86
+ /**
87
+ * Set the state
88
+ * @param {TrackedInstance} instance - The instance
89
+ * @param {string} key - The key
90
+ * @param {*} value - The value
91
+ * @returns
92
+ */
93
+ static setState(instance, key, value) {
94
+ instance.getAllData().set(key, value);
95
+ }
96
+ /**
97
+ * Get the state
98
+ * @param {TrackedInstance} instance - The instance
99
+ * @param {string} key - The key
100
+ * @returns {*} The state
101
+ */
102
+ static getState(instance, key) {
103
+ return instance.getAllData().get(key);
104
+ }
105
+ static isAutomationSession(instance) {
106
+ return AutomationFramework.getState(instance, AutomationFrameworkConstants.KEY_IS_BROWSERSTACK_HUB);
107
+ }
108
+ /**
109
+ * Set the driver for the automation framework instance
110
+ * @param {AutomationFrameworkInstance} instance - The automation framework instance
111
+ * @param {*} driver - The driver object
112
+ */
113
+ static setDriver(instance, driver) {
114
+ if (this.isAutomationSession(instance)) {
115
+ AutomationFramework.setState(instance, AutomationFramework.KEY_AUTOMATION_SESSIONS, driver);
116
+ }
117
+ else {
118
+ AutomationFramework.setState(instance, AutomationFramework.KEY_NON_BROWSERSTACK_AUTOMATION_SESSIONS, driver);
119
+ }
120
+ }
121
+ /**
122
+ * Get the driver from the automation framework instance
123
+ * @param {AutomationFrameworkInstance} instance - The automation framework instance
124
+ * @returns {*} The driver object or null
125
+ */
126
+ static getDriver(instance) {
127
+ let driver = null;
128
+ driver = this.isAutomationSession(instance) ? AutomationFramework.getState(instance, AutomationFramework.KEY_AUTOMATION_SESSIONS) || null : AutomationFramework.getState(instance, AutomationFramework.KEY_NON_BROWSERSTACK_AUTOMATION_SESSIONS) || null;
129
+ return driver;
130
+ }
131
+ }
@@ -0,0 +1,18 @@
1
+ export declare const AutomationFrameworkConstants: {
2
+ ENV_BROWSERSTACK_PLATFORM_INDEX: string;
3
+ KEY_HUB_URL: string;
4
+ KEY_FRAMEWORK_SESSION_ID: string;
5
+ KEY_INPUT_CAPABILITIES: string;
6
+ KEY_CAPABILITIES: string;
7
+ KEY_IS_BROWSERSTACK_HUB: string;
8
+ KEY_STARTED_AT: string;
9
+ KEY_ENDED_AT: string;
10
+ KEY_PLATFORM_INDEX: string;
11
+ COMMAND_NEW_SESSION: string;
12
+ COMMAND_GET: string;
13
+ COMMAND_SCREENSHOT: string;
14
+ COMMAND_W3C_EXECUTE_SCRIPT: string;
15
+ COMMAND_W3C_EXECUTE_SCRIPT_ASYNC: string;
16
+ COMMAND_QUIT: string;
17
+ };
18
+ //# sourceMappingURL=automationFrameworkConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automationFrameworkConstants.d.ts","sourceRoot":"","sources":["../../../../src/cli/frameworks/constants/automationFrameworkConstants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;CAgBxC,CAAA"}
@@ -0,0 +1,17 @@
1
+ export const AutomationFrameworkConstants = {
2
+ ENV_BROWSERSTACK_PLATFORM_INDEX: 'BROWSERSTACK_PLATFORM_INDEX',
3
+ KEY_HUB_URL: 'hub_url',
4
+ KEY_FRAMEWORK_SESSION_ID: 'framework_session_id',
5
+ KEY_INPUT_CAPABILITIES: 'input_capabilities',
6
+ KEY_CAPABILITIES: 'capabilities',
7
+ KEY_IS_BROWSERSTACK_HUB: 'is_browserstack_hub',
8
+ KEY_STARTED_AT: 'started_at',
9
+ KEY_ENDED_AT: 'ended_at',
10
+ KEY_PLATFORM_INDEX: 'platform_index',
11
+ COMMAND_NEW_SESSION: 'newsession',
12
+ COMMAND_GET: 'get',
13
+ COMMAND_SCREENSHOT: 'screenshot',
14
+ COMMAND_W3C_EXECUTE_SCRIPT: 'w3cexecutescript',
15
+ COMMAND_W3C_EXECUTE_SCRIPT_ASYNC: 'w3cexecutescriptasync',
16
+ COMMAND_QUIT: 'quit'
17
+ };
@@ -0,0 +1,43 @@
1
+ export declare const TestFrameworkConstants: {
2
+ KEY_TEST_UUID: string;
3
+ KEY_TEST_ID: string;
4
+ KEY_TEST_NAME: string;
5
+ KEY_TEST_FILE_PATH: string;
6
+ KEY_TEST_TAGS: string;
7
+ KEY_TEST_RESULT: string;
8
+ KEY_TEST_RESULT_AT: string;
9
+ KEY_TEST_STARTED_AT: string;
10
+ KEY_TEST_ENDED_AT: string;
11
+ KEY_TEST_LOCATION: string;
12
+ KEY_TEST_SCOPE: string;
13
+ KEY_TEST_SCOPES: string;
14
+ KEY_TEST_FRAMEWORK_NAME: string;
15
+ KEY_TEST_FRAMEWORK_VERSION: string;
16
+ KEY_TEST_CODE: string;
17
+ KEY_TEST_RERUN_NAME: string;
18
+ KEY_PLATFORM_INDEX: string;
19
+ KEY_TEST_FAILURE: string;
20
+ KEY_TEST_FAILURE_TYPE: string;
21
+ KEY_TEST_FAILURE_REASON: string;
22
+ KEY_TEST_LOGS: string;
23
+ KEY_TEST_META: string;
24
+ KEY_TEST_DEFERRED: string;
25
+ KEY_SESSION_NAME: string;
26
+ KEY_AUTOMATE_SESSION_NAME: string;
27
+ KEY_AUTOMATE_SESSION_STATUS: string;
28
+ KEY_AUTOMATE_SESSION_REASON: string;
29
+ KEY_EVENT_STARTED_AT: string;
30
+ KEY_EVENT_ENDED_AT: string;
31
+ KEY_HOOK_ID: string;
32
+ KEY_HOOK_RESULT: string;
33
+ KEY_HOOK_LOGS: string;
34
+ KEY_HOOK_NAME: string;
35
+ KEY_HOOKS_STARTED: string;
36
+ KEY_HOOKS_FINISHED: string;
37
+ DEFAULT_TEST_RESULT: string;
38
+ DEFAULT_HOOK_RESULT: string;
39
+ KIND_SCREENSHOT: string;
40
+ KIND_LOG: string;
41
+ HOOK_REGEX: string;
42
+ };
43
+ //# sourceMappingURL=testFrameworkConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testFrameworkConstants.d.ts","sourceRoot":"","sources":["../../../../src/cli/frameworks/constants/testFrameworkConstants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyClC,CAAA"}
@@ -0,0 +1,42 @@
1
+ export const TestFrameworkConstants = {
2
+ KEY_TEST_UUID: 'test_uuid',
3
+ KEY_TEST_ID: 'test_id',
4
+ KEY_TEST_NAME: 'test_name',
5
+ KEY_TEST_FILE_PATH: 'test_file_path',
6
+ KEY_TEST_TAGS: 'test_tags',
7
+ KEY_TEST_RESULT: 'test_result',
8
+ KEY_TEST_RESULT_AT: 'test_result_at',
9
+ KEY_TEST_STARTED_AT: 'test_started_at',
10
+ KEY_TEST_ENDED_AT: 'test_ended_at',
11
+ KEY_TEST_LOCATION: 'test_location',
12
+ KEY_TEST_SCOPE: 'test_scope',
13
+ KEY_TEST_SCOPES: 'test_scopes',
14
+ KEY_TEST_FRAMEWORK_NAME: 'test_framework_name',
15
+ KEY_TEST_FRAMEWORK_VERSION: 'test_framework_version',
16
+ KEY_TEST_CODE: 'test_code',
17
+ KEY_TEST_RERUN_NAME: 'test_rerun_name',
18
+ KEY_PLATFORM_INDEX: 'platform_index',
19
+ KEY_TEST_FAILURE: 'test_failure',
20
+ KEY_TEST_FAILURE_TYPE: 'test_failure_type',
21
+ KEY_TEST_FAILURE_REASON: 'test_failure_reason',
22
+ KEY_TEST_LOGS: 'test_logs',
23
+ KEY_TEST_META: 'test_meta',
24
+ KEY_TEST_DEFERRED: 'test_deferred',
25
+ KEY_SESSION_NAME: 'test_session_name',
26
+ KEY_AUTOMATE_SESSION_NAME: 'automate_session_name',
27
+ KEY_AUTOMATE_SESSION_STATUS: 'automate_session_status',
28
+ KEY_AUTOMATE_SESSION_REASON: 'automate_session_reason',
29
+ KEY_EVENT_STARTED_AT: 'event_started_at',
30
+ KEY_EVENT_ENDED_AT: 'event_ended_at',
31
+ KEY_HOOK_ID: 'hook_id',
32
+ KEY_HOOK_RESULT: 'hook_result',
33
+ KEY_HOOK_LOGS: 'hook_logs',
34
+ KEY_HOOK_NAME: 'hook_name',
35
+ KEY_HOOKS_STARTED: 'test_hooks_started',
36
+ KEY_HOOKS_FINISHED: 'test_hooks_finished',
37
+ DEFAULT_TEST_RESULT: 'pending',
38
+ DEFAULT_HOOK_RESULT: 'pending',
39
+ KIND_SCREENSHOT: 'TEST_SCREENSHOT',
40
+ KIND_LOG: 'TEST_LOG',
41
+ HOOK_REGEX: '^(BEFORE_|AFTER_)',
42
+ };
@@ -0,0 +1,89 @@
1
+ import type TrackedContext from '../instances/trackedContext.js';
2
+ import TrackedInstance from '../instances/trackedInstance.js';
3
+ import type TestFrameworkInstance from '../instances/testFrameworkInstance.js';
4
+ export default class TestFramework {
5
+ static instances: Map<any, any>;
6
+ testFrameworks: Array<string>;
7
+ testFrameworkVersions: Record<string, string>;
8
+ binSessionId: string | null;
9
+ /**
10
+ * Constructor for the TestFramework
11
+ * @param {Array} testFrameworks - List of Test frameworks
12
+ * @param {Map} testFrameworkVersions - Name of the Test frameworks
13
+ * @param {string} binSessionId - BinSessionId
14
+ */
15
+ constructor(testFrameworks: Array<string>, testFrameworkVersions: Record<string, string>, binSessionId: string);
16
+ /**
17
+ * get all instances
18
+ * @return {Map} - return all instances Map
19
+ */
20
+ getInstances(): Map<any, any>;
21
+ /**
22
+ * set testFrameworkInstance
23
+ * @param {TrackedContext} context
24
+ * @param {TestFrameworkInstance} instance
25
+ */
26
+ setInstance(context: TrackedContext, instance: TestFrameworkInstance): void;
27
+ /**
28
+ * Find instance and track any state for the test framework
29
+ * @returns instance
30
+ */
31
+ static getTrackedInstance(): any;
32
+ /**
33
+ * Set tracked instance
34
+ * @returns {string} The name of the test framework
35
+ */
36
+ static setTrackedInstance(context: TrackedContext, instance: TestFrameworkInstance): void;
37
+ /**
38
+ * get all test framework versions
39
+ * @returns {Map} - return all versions of framework available.
40
+ */
41
+ getTestFrameworksVersions(): Record<string, string>;
42
+ /**
43
+ * get all test frameworks
44
+ * @returns {Array} - return all test frameworks
45
+ */
46
+ getTestFrameworks(): string[];
47
+ /**
48
+ * Track an event
49
+ * @param {TestFrameworkState} testFrameworkState
50
+ * @param {HookState} hookState
51
+ * @param {*} args
52
+ * @returns {void}
53
+ */
54
+ trackEvent(testFrameworkState: State, hookState: State, args?: unknown): void;
55
+ /**
56
+ * run test hooks
57
+ * @param {TestFrameworkInstance} instance
58
+ * @param {TestFrameworkState} testFrameworkState
59
+ * @param {HookState} hookState
60
+ * @param {*} args
61
+ */
62
+ runHooks(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State, args?: unknown): Promise<void>;
63
+ /**
64
+ * Register an observer
65
+ * @param {TestFrameworkState} testFrameworkState
66
+ * @param {HookState} hookState
67
+ * @param {*} callback
68
+ * @returns {void}
69
+ */
70
+ static registerObserver(testFrameworkState: State, hookState: State, callback: Function): void;
71
+ /**
72
+ * Resolve instance for the test framework
73
+ * @param {TestFrameworkInstance} testFrameworkInstance
74
+ * @param {string} key
75
+ * @returns {TestFrameworkInstance}
76
+ */
77
+ static getState(instance: TestFrameworkInstance, key: string): any;
78
+ static hasState(instance: TestFrameworkInstance, key: string): boolean;
79
+ /**
80
+ * Set the state
81
+ * @param {TrackedInstance} instance - The instance
82
+ * @param {string} key - The key
83
+ * @param {*} value - The value
84
+ * @returns
85
+ */
86
+ static setState(instance: TrackedInstance, key: string, value: unknown): void;
87
+ updateInstanceState(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State): void;
88
+ }
89
+ //# sourceMappingURL=testFramework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testFramework.d.ts","sourceRoot":"","sources":["../../../src/cli/frameworks/testFramework.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAA;AAChE,OAAO,eAAe,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,qBAAqB,MAAM,uCAAuC,CAAA;AAE9E,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,MAAM,CAAC,SAAS,gBAAY;IAC5B,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAK;IAClC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAClD,YAAY,EAAE,MAAM,GAAC,IAAI,CAAO;IAEhC;;;;;IAKA;gBACY,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM;IAM9G;;;IAGA;IACA,YAAY;IAIZ;;;;IAIA;IACA,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,qBAAqB;IAIpE;;;IAGA;IACA,MAAM,CAAC,kBAAkB;IAKzB;;;KAGC;IACD,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,qBAAqB;IAIlF;;;KAGC;IACD,yBAAyB;IAIzB;;;KAGC;IACD,iBAAiB;IAIjB;;;;;;KAMC;IACD,UAAU,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,OAAY;IAI1E;;;;;;KAMC;IACK,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,OAAY;IAO/G;;;;;;KAMC;IACD,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;IAIvF;;;;;KAKC;IACD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,MAAM;IAI5D,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,MAAM;IAI5D;;;;;;KAMC;IACD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAItE,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK;CAOnG"}
@@ -0,0 +1,125 @@
1
+ import { CLIUtils } from '../cliUtils.js';
2
+ import { eventDispatcher } from '../eventDispatcher.js';
3
+ import { BStackLogger as logger } from '../cliLogger.js';
4
+ import TrackedInstance from '../instances/trackedInstance.js';
5
+ export default class TestFramework {
6
+ static instances = new Map();
7
+ testFrameworks = [];
8
+ testFrameworkVersions = {};
9
+ binSessionId = null;
10
+ /**
11
+ * Constructor for the TestFramework
12
+ * @param {Array} testFrameworks - List of Test frameworks
13
+ * @param {Map} testFrameworkVersions - Name of the Test frameworks
14
+ * @param {string} binSessionId - BinSessionId
15
+ */
16
+ constructor(testFrameworks, testFrameworkVersions, binSessionId) {
17
+ this.testFrameworks = testFrameworks;
18
+ this.testFrameworkVersions = testFrameworkVersions;
19
+ this.binSessionId = binSessionId;
20
+ }
21
+ /**
22
+ * get all instances
23
+ * @return {Map} - return all instances Map
24
+ */
25
+ getInstances() {
26
+ return TestFramework.instances;
27
+ }
28
+ /**
29
+ * set testFrameworkInstance
30
+ * @param {TrackedContext} context
31
+ * @param {TestFrameworkInstance} instance
32
+ */
33
+ setInstance(context, instance) {
34
+ TestFramework.instances.set(context.getId, instance);
35
+ }
36
+ /**
37
+ * Find instance and track any state for the test framework
38
+ * @returns instance
39
+ */
40
+ static getTrackedInstance() {
41
+ const ctx = TrackedInstance.createContext(CLIUtils.getCurrentInstanceName());
42
+ return TestFramework.instances.get(ctx.getId());
43
+ }
44
+ /**
45
+ * Set tracked instance
46
+ * @returns {string} The name of the test framework
47
+ */
48
+ static setTrackedInstance(context, instance) {
49
+ TestFramework.instances.set(context.getId(), instance);
50
+ }
51
+ /**
52
+ * get all test framework versions
53
+ * @returns {Map} - return all versions of framework available.
54
+ */
55
+ getTestFrameworksVersions() {
56
+ return this.testFrameworkVersions;
57
+ }
58
+ /**
59
+ * get all test frameworks
60
+ * @returns {Array} - return all test frameworks
61
+ */
62
+ getTestFrameworks() {
63
+ return this.testFrameworks;
64
+ }
65
+ /**
66
+ * Track an event
67
+ * @param {TestFrameworkState} testFrameworkState
68
+ * @param {HookState} hookState
69
+ * @param {*} args
70
+ * @returns {void}
71
+ */
72
+ trackEvent(testFrameworkState, hookState, args = {}) {
73
+ logger.info(`trackEvent: testFrameworkState=${testFrameworkState}; hookState=${hookState}; args=${args}`);
74
+ }
75
+ /**
76
+ * run test hooks
77
+ * @param {TestFrameworkInstance} instance
78
+ * @param {TestFrameworkState} testFrameworkState
79
+ * @param {HookState} hookState
80
+ * @param {*} args
81
+ */
82
+ async runHooks(instance, testFrameworkState, hookState, args = {}) {
83
+ logger.info(`runHooks: instance=${instance} automationFrameworkState=${testFrameworkState} hookState=${hookState}`);
84
+ const hookRegistryKey = CLIUtils.getHookRegistryKey(testFrameworkState, hookState);
85
+ await eventDispatcher.notifyObserver(hookRegistryKey, args);
86
+ }
87
+ /**
88
+ * Register an observer
89
+ * @param {TestFrameworkState} testFrameworkState
90
+ * @param {HookState} hookState
91
+ * @param {*} callback
92
+ * @returns {void}
93
+ */
94
+ static registerObserver(testFrameworkState, hookState, callback) {
95
+ eventDispatcher.registerObserver(CLIUtils.getHookRegistryKey(testFrameworkState, hookState), callback);
96
+ }
97
+ /**
98
+ * Resolve instance for the test framework
99
+ * @param {TestFrameworkInstance} testFrameworkInstance
100
+ * @param {string} key
101
+ * @returns {TestFrameworkInstance}
102
+ */
103
+ static getState(instance, key) {
104
+ return instance.getAllData().get(key);
105
+ }
106
+ static hasState(instance, key) {
107
+ return instance.hasData(key);
108
+ }
109
+ /**
110
+ * Set the state
111
+ * @param {TrackedInstance} instance - The instance
112
+ * @param {string} key - The key
113
+ * @param {*} value - The value
114
+ * @returns
115
+ */
116
+ static setState(instance, key, value) {
117
+ instance.getAllData().set(key, value);
118
+ }
119
+ updateInstanceState(instance, testFrameworkState, hookState) {
120
+ instance.setLastTestState(instance.getCurrentTestState());
121
+ instance.setLastHookState(instance.getCurrentHookState());
122
+ instance.setCurrentTestState(testFrameworkState);
123
+ instance.setCurrentHookState(hookState);
124
+ }
125
+ }
@@ -0,0 +1,28 @@
1
+ import AutomationFramework from './automationFramework.js';
2
+ /**
3
+ * WebdriverIO Framework class
4
+ */
5
+ export default class WdioAutomationFramework extends AutomationFramework {
6
+ constructor(automationFrameworkName: string, automationFrameworkVersion: string);
7
+ /**
8
+ * Find instance and track any state for the automation framework
9
+ * @param {*} automationFrameworkState
10
+ * @param {*} hookState
11
+ * @param {*} args
12
+ */
13
+ trackEvent(automationFrameworkState: State, hookState: State, args?: Record<string, unknown>): Promise<void>;
14
+ /**
15
+ * Resolve instance for the automation framework
16
+ * @param {*} automationFrameworkState
17
+ * @param {*} hookState
18
+ * @param {*} args
19
+ * @returns instance
20
+ */
21
+ resolveInstance(automationFrameworkState: State, hookState: State, args?: Record<string, unknown>): any;
22
+ /**
23
+ * Create instance for WebdriverIO
24
+ * @returns {void}
25
+ */
26
+ trackWebdriverIOInstance(automationFrameworkState: State, args?: Record<string, unknown>): void;
27
+ }
28
+ //# sourceMappingURL=wdioAutomationFramework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wdioAutomationFramework.d.ts","sourceRoot":"","sources":["../../../src/cli/frameworks/wdioAutomationFramework.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAO1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,mBAAmB;gBAExD,uBAAuB,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM;IAI/E;;;;;OAKG;IACG,UAAU,CAAC,wBAAwB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAatG;;;;;;OAMG;IACH,eAAe,CAAC,wBAAwB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAWrG;;;OAGG;IACH,wBAAwB,CAAC,wBAAwB,EAAE,KAAK,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAwB/F"}
@@ -0,0 +1,66 @@
1
+ import AutomationFramework from './automationFramework.js';
2
+ import { AutomationFrameworkState } from '../states/automationFrameworkState.js';
3
+ import { CLIUtils } from '../cliUtils.js';
4
+ import TrackedInstance from '../instances/trackedInstance.js';
5
+ import AutomationFrameworkInstance from '../instances/automationFrameworkInstance.js';
6
+ import { BStackLogger as logger } from '../cliLogger.js';
7
+ /**
8
+ * WebdriverIO Framework class
9
+ */
10
+ export default class WdioAutomationFramework extends AutomationFramework {
11
+ constructor(automationFrameworkName, automationFrameworkVersion) {
12
+ super(automationFrameworkName, automationFrameworkVersion);
13
+ }
14
+ /**
15
+ * Find instance and track any state for the automation framework
16
+ * @param {*} automationFrameworkState
17
+ * @param {*} hookState
18
+ * @param {*} args
19
+ */
20
+ async trackEvent(automationFrameworkState, hookState, args = {}) {
21
+ logger.info(`trackEvent: automationFrameworkState=${automationFrameworkState} hookState=${hookState}`);
22
+ await super.trackEvent(automationFrameworkState, hookState, args);
23
+ const instance = this.resolveInstance(automationFrameworkState, hookState, args);
24
+ if (instance === null) {
25
+ logger.error(`trackEvent: instance not found for automationFrameworkState=${automationFrameworkState} hookState=${hookState}`);
26
+ return;
27
+ }
28
+ args.instance = instance;
29
+ await this.runHooks(instance, automationFrameworkState, hookState, args);
30
+ }
31
+ /**
32
+ * Resolve instance for the automation framework
33
+ * @param {*} automationFrameworkState
34
+ * @param {*} hookState
35
+ * @param {*} args
36
+ * @returns instance
37
+ */
38
+ resolveInstance(automationFrameworkState, hookState, args = {}) {
39
+ let instance = null;
40
+ logger.info(`resolveInstance: resolving instance for automationFrameworkState=${automationFrameworkState} hookState=${hookState}`);
41
+ if (automationFrameworkState === AutomationFrameworkState.CREATE || automationFrameworkState === AutomationFrameworkState.NONE) {
42
+ this.trackWebdriverIOInstance(automationFrameworkState, args);
43
+ }
44
+ instance = AutomationFramework.getTrackedInstance();
45
+ return instance;
46
+ }
47
+ /**
48
+ * Create instance for WebdriverIO
49
+ * @returns {void}
50
+ */
51
+ trackWebdriverIOInstance(automationFrameworkState, args = {}) {
52
+ if (
53
+ // !args.browser &&
54
+ AutomationFramework.getTrackedInstance()) {
55
+ logger.info('trackWebdriverIOInstance: instance already exists');
56
+ return;
57
+ }
58
+ const target = CLIUtils.getCurrentInstanceName();
59
+ const trackedContext = TrackedInstance.createContext(target);
60
+ let instance = null;
61
+ logger.info(`trackWebdriverIOInstance: created instance for target=${target}, state=${automationFrameworkState}, args=${args}`);
62
+ instance = new AutomationFrameworkInstance(trackedContext, this.getAutomationFrameworkName(), this.getAutomationFrameworkVersion(), automationFrameworkState);
63
+ AutomationFramework.setTrackedInstance(trackedContext, instance);
64
+ logger.info(`trackWebdriverIOInstance: saved instance contextId=${trackedContext.getId()} target=${target}`);
65
+ }
66
+ }
@@ -0,0 +1,82 @@
1
+ import TestFramework from './testFramework.js';
2
+ import TestFrameworkInstance from '../instances/testFrameworkInstance.js';
3
+ import type { Frameworks } from '@wdio/types';
4
+ export default class WdioMochaTestFramework extends TestFramework {
5
+ static KEY_HOOK_LAST_STARTED: string;
6
+ static KEY_HOOK_LAST_FINISHED: string;
7
+ /**
8
+ * Constructor for the TestFramework
9
+ * @param {Array} testFrameworks - List of Test frameworks
10
+ * @param {Map} testFrameworkVersions - Name of the Test frameworks
11
+ * @param {string} binSessionId - BinSessionId
12
+ */
13
+ constructor(testFrameworks: string[], testFrameworkVersions: Record<string, string>, binSessionId: string);
14
+ /**
15
+ * Find instance and track any state for the test framework
16
+ * @param {TestFrameworkState} testFrameworkState
17
+ * @param {HookState} hookState
18
+ * @param {*} args
19
+ */
20
+ trackEvent(testFrameworkState: State, hookState: State, args?: Record<string, unknown>): Promise<void>;
21
+ /**
22
+ * Resolve instance for the test framework
23
+ * @param {TestFrameworkState} testFrameworkState
24
+ * @param {HookState} hookState
25
+ * @param {*} args
26
+ * @returns {TestFrameworkInstance}
27
+ */
28
+ resolveInstance(testFrameworkState: State, hookState: State, args?: Record<string, unknown>): TestFrameworkInstance | null;
29
+ /**
30
+ * Track WebdriverIO instance
31
+ * @param {TestFrameworkState} testFrameworkState
32
+ * @param {*} args
33
+ */
34
+ trackWdioMochaInstance(testFrameworkState: State, args: Record<string, unknown>): void;
35
+ getTestData(instance: TestFrameworkInstance, test: Frameworks.Test): Promise<Record<string, unknown>>;
36
+ loadTestResult(instance: TestFrameworkInstance, args: Record<string, unknown>): void;
37
+ /**
38
+ * Load log entries into the test framework instance.
39
+ * @param instance TestFrameworkInstance
40
+ * @param testFrameworkState TestFrameworkState
41
+ * @param hookState HookState
42
+ * @param args Additional arguments (level, message, etc.)
43
+ */
44
+ loadLogEntries(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State, logEntry: Record<string, unknown>): void;
45
+ /**
46
+ * Get the last active hook for the given instance and hook key.
47
+ * @param instance TestFrameworkInstance
48
+ * @param lastHookKey string
49
+ * @returns Record<string, unknown> | null
50
+ */
51
+ static lastActiveHook(instance: TestFrameworkInstance, lastHookKey: string): Record<string, unknown> | null;
52
+ /**
53
+ * Clear logs for a specific hook.
54
+ * @param instance TestFrameworkInstance
55
+ * @param lastHookKey string
56
+ */
57
+ static clearHookLogs(instance: TestFrameworkInstance, lastHookKey: string): void;
58
+ /**
59
+ * Clear all logs for the given instance, test framework state, and hook state.
60
+ * @param instance TestFrameworkInstance
61
+ * @param testFrameworkState TestFrameworkState
62
+ * @param hookState HookState
63
+ */
64
+ static clearLogs(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State): void;
65
+ /**
66
+ * Get all log entries for the given instance, test framework state, and hook state.
67
+ * @param instance TestFrameworkInstance
68
+ * @param testFrameworkState TestFrameworkState
69
+ * @param hookState HookState
70
+ * @returns unknown[]
71
+ */
72
+ static getLogEntries(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State): unknown[];
73
+ /**
74
+ * Track hook events for the test framework.
75
+ * @param instance TestFrameworkInstance
76
+ * @param testFrameworkState TestFrameworkState
77
+ * @param hookState HookState
78
+ * @param args Additional arguments (e.g., test result, test method)
79
+ */
80
+ trackHookEvents(instance: TestFrameworkInstance, testFrameworkState: State, hookState: State, args: Record<string, unknown>): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=wdioMochaTestFramework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wdioMochaTestFramework.d.ts","sourceRoot":"","sources":["../../../src/cli/frameworks/wdioMochaTestFramework.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAG9C,OAAO,qBAAqB,MAAM,uCAAuC,CAAA;AAKzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,aAAa;IAC7D,MAAM,CAAC,qBAAqB,SAA2B;IACvD,MAAM,CAAC,sBAAsB,SAA4B;IAEzD;;;;;IAKA;gBACY,cAAc,EAAE,MAAM,EAAE,EAAE,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM;IAIzG;;;;;IAKA;IACM,UAAU,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAoDhG;;;;;;KAMC;IACD,eAAe,CAAC,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,qBAAqB,GAAC,IAAI;IAa5H;;;;KAIC;IACD,sBAAsB,CAAC,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAqCzE,WAAW,CAAC,QAAQ,EAAE,qBAAqB,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI;IAmBxE,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAwB7E;;;;;;OAMG;IACH,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA6B9H;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAqB3G;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM;IAOzE;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK;IAY7F;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,GAAG,OAAO,EAAE;IAY7G;;;;;;OAMG;IACG,eAAe,CACjB,QAAQ,EAAE,qBAAqB,EAC/B,kBAAkB,EAAE,KAAK,EACzB,SAAS,EAAE,KAAK,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAwDpC"}