@wdio/utils 8.16.7 → 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.
- package/build/shim.d.ts +2 -1
- package/build/shim.d.ts.map +1 -1
- package/build/shim.js +15 -2
- package/package.json +2 -2
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
|
package/build/shim.d.ts.map
CHANGED
|
@@ -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,MAAM,EAAE,GAAG,CAAA;YACX,WAAW,EAAE,GAAG,CAAA;SACnB;KACJ;CACJ;AAaD,QAAA,MAAM,oBAAoB,YAAqD,GAAG,YAAY,MAAM,UAAS,QAAQ,GAAG,QAAQ,EAAE,SAAa,GAAG,EAAE,2BAsDnJ,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,mBAAwC,MAAM,MAAM,QAAQ,eAAa,GAAG,eAkL5F,CAAA;AAED
|
|
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,MAAM,EAAE,GAAG,CAAA;YACX,WAAW,EAAE,GAAG,CAAA;SACnB;KACJ;CACJ;AAaD,QAAA,MAAM,oBAAoB,YAAqD,GAAG,YAAY,MAAM,UAAS,QAAQ,GAAG,QAAQ,EAAE,SAAa,GAAG,EAAE,2BAsDnJ,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,mBAAwC,MAAM,MAAM,QAAQ,eAAa,GAAG,eAkL5F,CAAA;AAED;;;;;;;;GAQG;AACH,iBAAe,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,GAAE,GAAG,EAAO,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
|
@@ -225,12 +225,25 @@ const wrapCommand = function wrapCommand(commandName, fn) {
|
|
|
225
225
|
* @param {Function} fn spec or hook method
|
|
226
226
|
* @param {object} retries { limit: number, attempts: number }
|
|
227
227
|
* @param {Array} args arguments passed to hook
|
|
228
|
+
* @param {number} timeout The maximum time (in milliseconds) to wait for the function to complete
|
|
228
229
|
* @return {Promise} that gets resolved once test/hook is done or was retried enough
|
|
229
230
|
*/
|
|
230
|
-
async function executeAsync(fn, retries, args = []) {
|
|
231
|
+
async function executeAsync(fn, retries, args = [], timeout = 20000) {
|
|
231
232
|
this.wdioRetries = retries.attempts;
|
|
232
233
|
try {
|
|
233
|
-
|
|
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
|
+
]);
|
|
234
247
|
if (result && typeof result.finally === 'function') {
|
|
235
248
|
result.catch((err) => err);
|
|
236
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "8.16.
|
|
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",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a94335c7a66b9d4c792f0ae55a854f2c8b68e26d"
|
|
51
51
|
}
|