@wdio/utils 5.16.12 → 5.23.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.
- package/build/envDetector.js +1 -1
- package/build/initialisePlugin.js +5 -1
- package/build/monad.js +3 -0
- package/build/shim.js +41 -24
- package/build/test-framework/testFnWrapper.js +4 -4
- package/package.json +2 -2
package/build/envDetector.js
CHANGED
|
@@ -79,7 +79,7 @@ function sessionEnvironmentDetector({
|
|
|
79
79
|
isMobile: isMobile(capabilities),
|
|
80
80
|
isIOS: isIOS(capabilities),
|
|
81
81
|
isAndroid: isAndroid(capabilities),
|
|
82
|
-
isSauce: isSauce(requestedCapabilities
|
|
82
|
+
isSauce: isSauce(requestedCapabilities),
|
|
83
83
|
isSeleniumStandalone: isSeleniumStandalone(capabilities)
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -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/monad.js
CHANGED
|
@@ -33,6 +33,9 @@ function WebDriver(options, modifier, propertiesObject = {}) {
|
|
|
33
33
|
propertiesObject.options = {
|
|
34
34
|
value: options
|
|
35
35
|
};
|
|
36
|
+
propertiesObject.requestedCapabilities = {
|
|
37
|
+
value: options.requestedCapabilities
|
|
38
|
+
};
|
|
36
39
|
|
|
37
40
|
if (typeof commandWrapper === 'function') {
|
|
38
41
|
for (const [commandName, {
|
package/build/shim.js
CHANGED
|
@@ -10,6 +10,7 @@ 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;
|
|
13
14
|
let hasWdioSyncSupport = false;
|
|
14
15
|
exports.hasWdioSyncSupport = hasWdioSyncSupport;
|
|
15
16
|
let runSync = null;
|
|
@@ -56,30 +57,44 @@ let runFnInFiberContext = function (fn) {
|
|
|
56
57
|
|
|
57
58
|
exports.runFnInFiberContext = runFnInFiberContext;
|
|
58
59
|
|
|
59
|
-
let wrapCommand =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let commandError;
|
|
60
|
+
let wrapCommand = function wrapCommand(commandName, fn) {
|
|
61
|
+
return async function wrapCommandFn(...args) {
|
|
62
|
+
const beforeHookArgs = [commandName, args];
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if (!inCommandHook && this.options.beforeCommand) {
|
|
65
|
+
inCommandHook = true;
|
|
66
|
+
await executeHooksWithArgs.call(this, this.options.beforeCommand, beforeHookArgs);
|
|
67
|
+
inCommandHook = false;
|
|
68
|
+
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
let commandResult;
|
|
71
|
+
let commandError;
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
try {
|
|
74
|
+
commandResult = await fn.apply(this, args);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
commandError = err;
|
|
77
|
+
}
|
|
75
78
|
|
|
76
|
-
|
|
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
|
+
};
|
|
77
92
|
};
|
|
78
93
|
|
|
79
94
|
exports.wrapCommand = wrapCommand;
|
|
80
95
|
|
|
81
96
|
let executeSync = async function (fn, retries, args = []) {
|
|
82
|
-
this.
|
|
97
|
+
this.wdioRetries = retries.attempts;
|
|
83
98
|
|
|
84
99
|
try {
|
|
85
100
|
let res = fn.apply(this, args);
|
|
@@ -102,7 +117,7 @@ let executeSync = async function (fn, retries, args = []) {
|
|
|
102
117
|
exports.executeSync = executeSync;
|
|
103
118
|
|
|
104
119
|
const executeAsync = async function (fn, retries, args = []) {
|
|
105
|
-
this.
|
|
120
|
+
this.wdioRetries = retries.attempts;
|
|
106
121
|
|
|
107
122
|
try {
|
|
108
123
|
return await fn.apply(this, args);
|
|
@@ -119,12 +134,14 @@ const executeAsync = async function (fn, retries, args = []) {
|
|
|
119
134
|
exports.executeAsync = executeAsync;
|
|
120
135
|
|
|
121
136
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
}
|
|
130
147
|
} catch (_unused) {}
|
|
@@ -13,7 +13,7 @@ var _shim = require("../shim");
|
|
|
13
13
|
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
17
|
|
|
18
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
19
|
|
|
@@ -46,7 +46,7 @@ const testFrameworkFnWrapper = async function ({
|
|
|
46
46
|
limit: repeatTest
|
|
47
47
|
};
|
|
48
48
|
const beforeArgs = mochaJasmineCompatibility(beforeFnArgs(this), this);
|
|
49
|
-
await (0, _errorHandler.logHookError)(`Before${type}`,
|
|
49
|
+
await (0, _errorHandler.logHookError)(`Before${type}`, await executeHooksWithArgs(beforeFn, beforeArgs), cid);
|
|
50
50
|
let promise;
|
|
51
51
|
let result;
|
|
52
52
|
let error;
|
|
@@ -82,7 +82,7 @@ const testFrameworkFnWrapper = async function ({
|
|
|
82
82
|
afterArgs = mochaJasmineCompatibility(afterArgs, this);
|
|
83
83
|
afterArgs = mochaJasmineResultCompatibility(afterArgs, error, duration);
|
|
84
84
|
afterArgs = cucumberCompatibility(afterArgs);
|
|
85
|
-
await (0, _errorHandler.logHookError)(`After${type}`,
|
|
85
|
+
await (0, _errorHandler.logHookError)(`After${type}`, await executeHooksWithArgs(afterFn, [...afterArgs]), cid);
|
|
86
86
|
|
|
87
87
|
if (error) {
|
|
88
88
|
throw error;
|
|
@@ -113,7 +113,7 @@ const mochaJasmineResultCompatibility = (afterArgs, error, duration) => {
|
|
|
113
113
|
let args = afterArgs;
|
|
114
114
|
|
|
115
115
|
if (afterArgs.length === 3 && afterArgs[0] && typeof afterArgs[0] === 'object') {
|
|
116
|
-
args = [_objectSpread({}, afterArgs[0], {
|
|
116
|
+
args = [_objectSpread(_objectSpread({}, afterArgs[0]), {}, {
|
|
117
117
|
error,
|
|
118
118
|
duration,
|
|
119
119
|
passed: !error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.23.0",
|
|
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": "a9b8098ad18074e05a72c0458a7845a41a40aa93"
|
|
41
41
|
}
|