@wdio/utils 5.16.11 → 5.18.6
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/initialisePlugin.js +5 -1
- package/build/shim.js +80 -18
- package/package.json +2 -2
|
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = initialisePlugin;
|
|
7
7
|
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
8
10
|
var _utils = require("./utils");
|
|
9
11
|
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
function initialisePlugin(name, type, target = 'default') {
|
|
11
|
-
if (name[0] === '@') {
|
|
15
|
+
if (name[0] === '@' || _path.default.isAbsolute(name)) {
|
|
12
16
|
const service = (0, _utils.safeRequire)(name);
|
|
13
17
|
return service[target];
|
|
14
18
|
}
|
package/build/shim.js
CHANGED
|
@@ -10,6 +10,11 @@ var _logger = _interopRequireDefault(require("@wdio/logger"));
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
12
|
const log = (0, _logger.default)('@wdio/utils:shim');
|
|
13
|
+
let inCommandHook = false;
|
|
14
|
+
let hasWdioSyncSupport = false;
|
|
15
|
+
exports.hasWdioSyncSupport = hasWdioSyncSupport;
|
|
16
|
+
let runSync = null;
|
|
17
|
+
exports.runSync = runSync;
|
|
13
18
|
|
|
14
19
|
let executeHooksWithArgs = async function executeHooksWithArgsShim(hooks, args) {
|
|
15
20
|
if (!Array.isArray(hooks)) {
|
|
@@ -52,34 +57,91 @@ let runFnInFiberContext = function (fn) {
|
|
|
52
57
|
|
|
53
58
|
exports.runFnInFiberContext = runFnInFiberContext;
|
|
54
59
|
|
|
55
|
-
let wrapCommand = (
|
|
60
|
+
let wrapCommand = function wrapCommand(commandName, fn) {
|
|
61
|
+
return async function wrapCommandFn(...args) {
|
|
62
|
+
const beforeHookArgs = [commandName, args];
|
|
63
|
+
|
|
64
|
+
if (!inCommandHook && this.options.beforeCommand) {
|
|
65
|
+
inCommandHook = true;
|
|
66
|
+
await executeHooksWithArgs.call(this, this.options.beforeCommand, beforeHookArgs);
|
|
67
|
+
inCommandHook = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let commandResult;
|
|
71
|
+
let commandError;
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
commandResult = await fn.apply(this, args);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
commandError = err;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!inCommandHook && this.options.afterCommand) {
|
|
80
|
+
inCommandHook = true;
|
|
81
|
+
const afterHookArgs = [...beforeHookArgs, commandResult, commandError];
|
|
82
|
+
await executeHooksWithArgs.call(this, this.options.afterCommand, afterHookArgs);
|
|
83
|
+
inCommandHook = false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (commandError) {
|
|
87
|
+
throw commandError;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return commandResult;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
56
93
|
|
|
57
94
|
exports.wrapCommand = wrapCommand;
|
|
58
|
-
let hasWdioSyncSupport = false;
|
|
59
|
-
exports.hasWdioSyncSupport = hasWdioSyncSupport;
|
|
60
95
|
|
|
61
|
-
let executeSync = function (fn,
|
|
62
|
-
|
|
96
|
+
let executeSync = async function (fn, retries, args = []) {
|
|
97
|
+
this.wdioRetries = retries.attempts;
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
let res = fn.apply(this, args);
|
|
101
|
+
|
|
102
|
+
if (res instanceof Promise) {
|
|
103
|
+
return await res;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return res;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
if (retries.limit > retries.attempts) {
|
|
109
|
+
retries.attempts++;
|
|
110
|
+
return await executeSync.call(this, fn, retries, args);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return Promise.reject(e);
|
|
114
|
+
}
|
|
63
115
|
};
|
|
64
116
|
|
|
65
117
|
exports.executeSync = executeSync;
|
|
66
118
|
|
|
67
|
-
|
|
68
|
-
|
|
119
|
+
const executeAsync = async function (fn, retries, args = []) {
|
|
120
|
+
this.wdioRetries = retries.attempts;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
return await fn.apply(this, args);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (retries.limit > retries.attempts) {
|
|
126
|
+
retries.attempts++;
|
|
127
|
+
return await executeAsync.call(this, fn, retries, args);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
69
132
|
};
|
|
70
133
|
|
|
71
134
|
exports.executeAsync = executeAsync;
|
|
72
|
-
let runSync = null;
|
|
73
|
-
exports.runSync = runSync;
|
|
74
135
|
|
|
75
136
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
137
|
+
if (!process.env.WDIO_NO_SYNC_SUPPORT) {
|
|
138
|
+
const wdioSync = require('@wdio/sync');
|
|
139
|
+
|
|
140
|
+
exports.hasWdioSyncSupport = hasWdioSyncSupport = true;
|
|
141
|
+
exports.runFnInFiberContext = runFnInFiberContext = wdioSync.runFnInFiberContext;
|
|
142
|
+
exports.wrapCommand = wrapCommand = wdioSync.wrapCommand;
|
|
143
|
+
exports.executeHooksWithArgs = executeHooksWithArgs = wdioSync.executeHooksWithArgs;
|
|
144
|
+
exports.executeSync = executeSync = wdioSync.executeSync;
|
|
145
|
+
exports.runSync = runSync = wdioSync.runSync;
|
|
146
|
+
}
|
|
85
147
|
} catch (_unused) {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.6",
|
|
4
4
|
"description": "A WDIO helper utility to provide several utility functions used across the project.",
|
|
5
5
|
"author": "Christian Bromann <christian@saucelabs.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-utils",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "fa344d53871401ad3a6513ffa16ed4f9d2218f59"
|
|
41
41
|
}
|