@wdio/sync
Advanced tools
Comparing version 5.11.13 to 5.12.0
@@ -8,3 +8,3 @@ "use strict"; | ||
const STACK_START = /^\s+at /; | ||
const STACKTRACE_FILTER = ['node_modules/@wdio/sync/', 'node_modules/webdriverio/build/', ' (events.js:', ' (domain.js:', '(internal/process/next_tick.js', 'new Promise (<anonymous>)', 'Generator.next (<anonymous>)', '__awaiter (']; | ||
const STACKTRACE_FILTER = ['node_modules/@wdio/sync/', 'node_modules/webdriverio/build/', 'node_modules/webdriver/build/', 'node_modules/request/request', ' (events.js:', ' (domain.js:', '(internal/process/next_tick.js', 'new Promise (<anonymous>)', 'Generator.next (<anonymous>)', '__awaiter (']; | ||
@@ -11,0 +11,0 @@ const STACKTRACE_FILTER_FN = stackRow => { |
@@ -21,5 +21,3 @@ "use strict"; | ||
} else { | ||
({ | ||
name | ||
} = savedError); | ||
name = 'Error'; | ||
message = commandError; | ||
@@ -30,11 +28,11 @@ } | ||
err.name = name; | ||
err.stack = savedError.stack; | ||
let stackArr = savedError.stack.split('\n'); | ||
if (stack) { | ||
err.stack = stack + '\n' + err.stack; | ||
stack = stack.replace(`${err.name}: ${err.name}`, err.name); | ||
stackArr[0] = '\n'; | ||
stackArr = [...stack.split('\n'), ...stackArr]; | ||
} | ||
let stackArr = err.stack.split('\n'); | ||
stackArr = stackArr.filter(_constants.STACKTRACE_FILTER_FN); | ||
err.stack = stackArr.reduce((acc, currentValue) => { | ||
err.stack = stackArr.filter(_constants.STACKTRACE_FILTER_FN).reduce((acc, currentValue) => { | ||
return acc.includes(currentValue) ? acc : `${acc}\n${currentValue}`; | ||
@@ -41,0 +39,0 @@ }, '').trim(); |
@@ -18,7 +18,5 @@ "use strict"; | ||
return function wrapCommandFn(...args) { | ||
const stackError = new Error(); | ||
if (this._NOT_FIBER === true) { | ||
this._NOT_FIBER = isNotInFiber(this, fn.name); | ||
return runCommand.apply(this, [fn, stackError, ...args]); | ||
return fn.apply(this, args); | ||
} | ||
@@ -28,3 +26,3 @@ | ||
const future = new _future.default(); | ||
const result = runCommandWithHooks.apply(this, [commandName, fn, stackError, ...args]); | ||
const result = runCommandWithHooks.apply(this, [commandName, fn, ...args]); | ||
result.then(future.return.bind(future), future.throw.bind(future)); | ||
@@ -51,3 +49,4 @@ | ||
async function runCommandWithHooks(commandName, fn, stackError, ...args) { | ||
async function runCommandWithHooks(commandName, fn, ...args) { | ||
const stackError = new Error(); | ||
await (0, _executeHooksWithArgs.default)(this.options.beforeCommand, [commandName, args]); | ||
@@ -58,5 +57,5 @@ let commandResult; | ||
try { | ||
commandResult = await runCommand.apply(this, [fn, stackError, ...args]); | ||
commandResult = await fn.apply(this, args); | ||
} catch (err) { | ||
commandError = err; | ||
commandError = (0, _utils.sanitizeErrorMessage)(err, stackError); | ||
} | ||
@@ -73,10 +72,2 @@ | ||
async function runCommand(fn, stackError, ...args) { | ||
try { | ||
return await fn.apply(this, args); | ||
} catch (err) { | ||
throw (0, _utils.sanitizeErrorMessage)(err, stackError); | ||
} | ||
} | ||
function isNotInFiber(context, fnName) { | ||
@@ -83,0 +74,0 @@ return fnName !== '' && !!(context.elementId || context.parent && context.parent.elementId); |
{ | ||
"name": "@wdio/sync", | ||
"version": "5.11.13", | ||
"version": "5.12.0", | ||
"description": "A WebdriverIO plugin. Helper module to run WebdriverIO commands synchronously", | ||
@@ -10,3 +10,3 @@ "author": "Christian Bromann <christian@saucelabs.com>", | ||
"engines": { | ||
"node": ">= 8.11.0" | ||
"node": ">= 10.13.0" | ||
}, | ||
@@ -38,4 +38,4 @@ "scripts": { | ||
"dependencies": { | ||
"@wdio/config": "^5.11.0", | ||
"@wdio/logger": "^5.11.0", | ||
"@wdio/config": "^5.12.0", | ||
"@wdio/logger": "^5.12.0", | ||
"fibers": "^4.0.0" | ||
@@ -46,3 +46,3 @@ }, | ||
}, | ||
"gitHead": "840579acb9ba9de6d020e7fe9d227941524cc2f5" | ||
"gitHead": "187c8f044e252877533e53ee2b645f56416d5a41" | ||
} |
@@ -303,3 +303,3 @@ /// <reference types="node"/> | ||
): Cookie[]; | ||
getWindowSize(): object; | ||
getWindowSize(): WebDriver.RectReturn; | ||
keys( | ||
@@ -351,3 +351,3 @@ value: string | string[] | ||
localPath: string | ||
): void; | ||
): string; | ||
url( | ||
@@ -354,0 +354,0 @@ url?: string |
23768
665
Updated@wdio/config@^5.12.0
Updated@wdio/logger@^5.12.0