@wdio/utils 8.16.3 → 8.16.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/driver/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAgGxD,wBAAsB,WAAW,CAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,kBAAkB,kCAezH;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,kBAAkB,kCAYpH"}
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/driver/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA4GxD,wBAAsB,WAAW,CAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,kBAAkB,kCAezH;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,kBAAkB,kCAYpH"}
@@ -14,7 +14,12 @@ function mapCapabilities(options, caps, task, taskItemLabel) {
14
14
  const multiremoteCaps = cap;
15
15
  const isMultiremote = Boolean(multiremoteCaps[Object.keys(cap)[0]].capabilities);
16
16
  if (isMultiremote) {
17
- return Object.values(multiremoteCaps).map((c) => c.capabilities);
17
+ return Object.values(multiremoteCaps).map((c) => {
18
+ if (c.automationProtocol === 'devtools') {
19
+ return;
20
+ }
21
+ return c.capabilities;
22
+ });
18
23
  }
19
24
  else if (w3cCaps.alwaysMatch) {
20
25
  return w3cCaps.alwaysMatch;
@@ -23,6 +28,9 @@ function mapCapabilities(options, caps, task, taskItemLabel) {
23
28
  }).flat()
24
29
  : Object.values(caps).map((mrOpts) => {
25
30
  const w3cCaps = mrOpts.capabilities;
31
+ if (mrOpts.automationProtocol === 'devtools') {
32
+ return;
33
+ }
26
34
  if (w3cCaps.alwaysMatch) {
27
35
  return w3cCaps.alwaysMatch;
28
36
  }
@@ -31,14 +39,18 @@ function mapCapabilities(options, caps, task, taskItemLabel) {
31
39
  /**
32
40
  * only set up driver if
33
41
  */
34
- // - browserName is defined so we know it is a browser session
35
- cap.browserName &&
42
+ // - capabilities are defined and not empty because automationProtocol is set to `devtools`
43
+ cap &&
44
+ // - browserName is defined so we know it is a browser session
45
+ cap.browserName &&
36
46
  // - we are not about to run a cloud session
37
47
  !definesRemoteDriver(options) &&
38
48
  // - we are not running Safari (driver already installed on macOS)
39
49
  !isSafari(cap.browserName) &&
40
50
  // - driver options don't define a binary path
41
- !getDriverOptions(cap).binary));
51
+ !getDriverOptions(cap).binary &&
52
+ // - user is not defining "devtools" as automation protocol
53
+ options.automationProtocol !== 'devtools'));
42
54
  /**
43
55
  * nothing to setup
44
56
  */
@@ -38,7 +38,7 @@ export function getBuildIdByChromePath(chromePath) {
38
38
  const oldest = versions.sort((a, b) => a > b ? -1 : 1)[0];
39
39
  return oldest;
40
40
  }
41
- const versionString = cp.execSync(`"${chromePath}" --version`).toString();
41
+ const versionString = cp.execSync(`"${chromePath}" --version --no-sandbox`).toString();
42
42
  return versionString.trim().split(' ').pop()?.trim();
43
43
  }
44
44
  export async function getBuildIdByFirefoxPath(firefoxPath) {
@@ -74,7 +74,7 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
74
74
  await fsp.mkdir(cacheDir, { recursive: true });
75
75
  }
76
76
  /**
77
- * don't set up Chrome if a binary was defined in caps
77
+ * don't set up Chrome/Firefox if a binary was defined in caps
78
78
  */
79
79
  const browserOptions = (browserName === Browser.CHROME
80
80
  ? caps['goog:chromeOptions']
@@ -99,7 +99,7 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
99
99
  ? getBuildIdByChromePath(executablePath)
100
100
  : await getBuildIdByFirefoxPath(executablePath);
101
101
  /**
102
- * verify that we have a valid Chrome browser installed
102
+ * verify that we have a valid Chrome/Firefox browser installed
103
103
  */
104
104
  if (tag) {
105
105
  return {
@@ -109,7 +109,7 @@ export async function setupPuppeteerBrowser(cacheDir, caps) {
109
109
  }
110
110
  }
111
111
  /**
112
- * otherwise download provided Chrome browser version or "stable"
112
+ * otherwise download provided Chrome/Firefox browser version or "stable"
113
113
  */
114
114
  const tag = browserName === Browser.CHROME
115
115
  ? caps.browserVersion || ChromeReleaseChannel.STABLE
package/build/shim.d.ts CHANGED
@@ -26,8 +26,9 @@ declare const wrapCommand: <T>(commandName: string, fn: Function) => (...args: a
26
26
  * @param {Function} fn spec or hook method
27
27
  * @param {object} retries { limit: number, attempts: number }
28
28
  * @param {Array} args arguments passed to hook
29
+ * @param {number} timeout The maximum time (in milliseconds) to wait for the function to complete
29
30
  * @return {Promise} that gets resolved once test/hook is done or was retried enough
30
31
  */
31
- declare function executeAsync(this: any, fn: Function, retries: Retries, args?: any[]): Promise<unknown>;
32
+ declare function executeAsync(this: any, fn: Function, retries: Retries, args?: any[], timeout?: number): Promise<unknown>;
32
33
  export { executeHooksWithArgs, wrapCommand, executeAsync, };
33
34
  //# sourceMappingURL=shim.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shim.d.ts","sourceRoot":"","sources":["../src/shim.ts"],"names":[],"mappings":"AASA,UAAU,OAAO;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,WAAW,EAAE,GAAG,CAAA;CACvB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM,CAAC;QACb,UAAU,MAAM;YACZ,MAA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,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BlI;AAED,OAAO,EACH,oBAAoB,EACpB,WAAW,EACX,YAAY,GACf,CAAA"}
package/build/shim.js CHANGED
@@ -25,12 +25,21 @@ const executeHooksWithArgs = async function executeHooksWithArgsShim(hookName, h
25
25
  if (!Array.isArray(args)) {
26
26
  args = [args];
27
27
  }
28
- const hooksPromises = hooks.map((hook) => new Promise((resolve) => {
28
+ const hooksPromises = hooks.map((hook) => new Promise((resolve, reject) => {
29
29
  let result;
30
30
  try {
31
31
  result = hook.apply(this, args);
32
32
  }
33
33
  catch (e) {
34
+ /**
35
+ * When we use `this.skip()` inside a test or a hook, it's a signal that we want to stop that particular test.
36
+ * Mocha, the testing framework, knows how to handle this for its own built-in hooks and test steps.
37
+ * However, for our custom hooks, we need to reject the promise, which effectively skips the test case.
38
+ * For more details, refer to: https://github.com/mochajs/mocha/pull/3859#issuecomment-534116333
39
+ */
40
+ if (/^(sync|async) skip; aborting execution$/.test(e.message)) {
41
+ return reject();
42
+ }
34
43
  log.error(e.stack);
35
44
  return resolve(e);
36
45
  }
@@ -216,12 +225,25 @@ const wrapCommand = function wrapCommand(commandName, fn) {
216
225
  * @param {Function} fn spec or hook method
217
226
  * @param {object} retries { limit: number, attempts: number }
218
227
  * @param {Array} args arguments passed to hook
228
+ * @param {number} timeout The maximum time (in milliseconds) to wait for the function to complete
219
229
  * @return {Promise} that gets resolved once test/hook is done or was retried enough
220
230
  */
221
- async function executeAsync(fn, retries, args = []) {
231
+ async function executeAsync(fn, retries, args = [], timeout = 20000) {
222
232
  this.wdioRetries = retries.attempts;
223
233
  try {
224
- const result = fn.apply(this, args);
234
+ // @ts-expect-error
235
+ const _timeout = this?._runnable?._timeout || globalThis.jasmine?.DEFAULT_TIMEOUT_INTERVAL || timeout;
236
+ /**
237
+ * Executes the function with specified timeout and returns the result, or throws an error if the timeout is exceeded.
238
+ */
239
+ const result = await Promise.race([
240
+ fn.apply(this, args),
241
+ new Promise((resolve, reject) => {
242
+ setTimeout(() => {
243
+ reject(new Error('Timeout'));
244
+ }, _timeout);
245
+ })
246
+ ]);
225
247
  if (result && typeof result.finally === 'function') {
226
248
  result.catch((err) => err);
227
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/utils",
3
- "version": "8.16.3",
3
+ "version": "8.16.9",
4
4
  "description": "A WDIO helper utility to provide several utility functions used across the project.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-utils",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@puppeteer/browsers": "^1.6.0",
34
34
  "@wdio/logger": "8.11.0",
35
- "@wdio/types": "8.16.3",
35
+ "@wdio/types": "8.16.7",
36
36
  "decamelize": "^6.0.0",
37
37
  "deepmerge-ts": "^5.1.0",
38
38
  "edgedriver": "^5.3.5",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "2c05558b0e4d6ecdca5eb7b0ed37d4a4e733b5a5"
50
+ "gitHead": "a94335c7a66b9d4c792f0ae55a854f2c8b68e26d"
51
51
  }