@wdio/utils 6.0.11 → 6.1.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/index.js +6 -0
- package/build/initialiseServices.js +1 -1
- package/build/utils.js +31 -0
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -57,6 +57,12 @@ Object.defineProperty(exports, "isFunctionAsync", {
|
|
|
57
57
|
return _utils.isFunctionAsync;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "transformCommandLogResult", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _utils.transformCommandLogResult;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
60
66
|
Object.defineProperty(exports, "wrapCommand", {
|
|
61
67
|
enumerable: true,
|
|
62
68
|
get: function () {
|
|
@@ -17,7 +17,7 @@ const log = (0, _logger.default)('@wdio/utils:initialiseServices');
|
|
|
17
17
|
function initialiseServices(services) {
|
|
18
18
|
const initialisedServices = [];
|
|
19
19
|
|
|
20
|
-
for (let [serviceName, serviceConfig] of services) {
|
|
20
|
+
for (let [serviceName, serviceConfig = {}] of services) {
|
|
21
21
|
if (typeof serviceName === 'object') {
|
|
22
22
|
log.debug('initialise custom initiated service');
|
|
23
23
|
initialisedServices.push([serviceName, {}]);
|
package/build/utils.js
CHANGED
|
@@ -5,11 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.overwriteElementCommands = overwriteElementCommands;
|
|
7
7
|
exports.commandCallStructure = commandCallStructure;
|
|
8
|
+
exports.transformCommandLogResult = transformCommandLogResult;
|
|
8
9
|
exports.isValidParameter = isValidParameter;
|
|
9
10
|
exports.getArgumentType = getArgumentType;
|
|
10
11
|
exports.safeRequire = safeRequire;
|
|
11
12
|
exports.isFunctionAsync = isFunctionAsync;
|
|
12
13
|
exports.filterSpecArgs = filterSpecArgs;
|
|
14
|
+
exports.isBase64 = isBase64;
|
|
15
|
+
const SCREENSHOT_REPLACEMENT = '"<Screenshot[base64]>"';
|
|
13
16
|
|
|
14
17
|
function overwriteElementCommands(propertiesObject) {
|
|
15
18
|
const elementOverrides = propertiesObject['__elementOverrides__'] ? propertiesObject['__elementOverrides__'].value : {};
|
|
@@ -54,6 +57,8 @@ function commandCallStructure(commandName, args) {
|
|
|
54
57
|
const callArgs = args.map(arg => {
|
|
55
58
|
if (typeof arg === 'string' && (arg.startsWith('!function(') || arg.startsWith('return (function'))) {
|
|
56
59
|
arg = '<fn>';
|
|
60
|
+
} else if (typeof arg === 'string' && isBase64(arg)) {
|
|
61
|
+
arg = SCREENSHOT_REPLACEMENT;
|
|
57
62
|
} else if (typeof arg === 'string') {
|
|
58
63
|
arg = `"${arg}"`;
|
|
59
64
|
} else if (typeof arg === 'function') {
|
|
@@ -71,6 +76,14 @@ function commandCallStructure(commandName, args) {
|
|
|
71
76
|
return `${commandName}(${callArgs})`;
|
|
72
77
|
}
|
|
73
78
|
|
|
79
|
+
function transformCommandLogResult(result) {
|
|
80
|
+
if (typeof result.file === 'string' && isBase64(result.file)) {
|
|
81
|
+
return SCREENSHOT_REPLACEMENT;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
function isValidParameter(arg, expectedType) {
|
|
75
88
|
let shouldBeArray = false;
|
|
76
89
|
|
|
@@ -135,4 +148,22 @@ function isFunctionAsync(fn) {
|
|
|
135
148
|
|
|
136
149
|
function filterSpecArgs(args) {
|
|
137
150
|
return args.filter(arg => typeof arg !== 'function');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isBase64(str) {
|
|
154
|
+
var notBase64 = new RegExp('[^A-Z0-9+\\/=]', 'i');
|
|
155
|
+
const isString = typeof str === 'string' || str instanceof String;
|
|
156
|
+
|
|
157
|
+
if (!isString) {
|
|
158
|
+
throw new Error('Expected string but received invalid type.');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const len = str.length;
|
|
162
|
+
|
|
163
|
+
if (!len || len % 4 !== 0 || notBase64.test(str)) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const firstPaddingChar = str.indexOf('=');
|
|
168
|
+
return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
|
|
138
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@wdio/logger": "6.0.
|
|
34
|
+
"@wdio/logger": "6.0.16"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "15034d0acef9a6de046df31f60850023cb52bce9"
|
|
40
40
|
}
|