Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/utils

Package Overview
Dependencies
Maintainers
2
Versions
298
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/utils - npm Package Compare versions

Comparing version 6.6.3 to 6.7.0

build/test-framework/types.d.ts

43

build/envDetector.d.ts

@@ -1,6 +0,39 @@

export function isW3C(capabilities: Object): boolean;
export function capabilitiesEnvironmentDetector(capabilities: Object, automationProtocol?: string | undefined): Object;
export function sessionEnvironmentDetector({ capabilities, requestedCapabilities }: Object): Object;
export function devtoolsEnvironmentDetector({ browserName }: Object): Object;
export function webdriverEnvironmentDetector(capabilities: Object): Object;
/// <reference types="webdriver" />
export declare function isW3C(capabilities?: WebDriver.DesiredCapabilities): boolean;
export declare function capabilitiesEnvironmentDetector(capabilities: WebDriver.Capabilities, automationProtocol: string): {
isChrome: boolean;
isMobile: boolean;
isIOS: boolean;
isAndroid: boolean;
isSauce: boolean;
};
export declare function sessionEnvironmentDetector({ capabilities, requestedCapabilities }: {
capabilities?: WebDriver.DesiredCapabilities;
requestedCapabilities?: WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities;
}): {
isW3C: boolean;
isChrome: boolean;
isMobile: boolean;
isIOS: boolean;
isAndroid: boolean;
isSauce: boolean;
isSeleniumStandalone: boolean;
};
export declare function devtoolsEnvironmentDetector({ browserName }: WebDriver.Capabilities): {
isDevTools: boolean;
isW3C: boolean;
isMobile: boolean;
isIOS: boolean;
isAndroid: boolean;
isChrome: boolean;
isSauce: boolean;
isSeleniumStandalone: boolean;
};
export declare function webdriverEnvironmentDetector(capabilities: WebDriver.Capabilities): {
isChrome: boolean;
isMobile: boolean;
isIOS: boolean;
isAndroid: boolean;
isSauce: boolean;
};
//# sourceMappingURL=envDetector.d.ts.map

57

build/envDetector.js

@@ -13,4 +13,6 @@ "use strict";

}
const isAppium = capabilities.automationName || capabilities.deviceName || (capabilities.appiumVersion);
const hasW3CCaps = (capabilities.platformName &&
const isAppium = Boolean(capabilities.automationName ||
capabilities.deviceName ||
capabilities.appiumVersion);
const hasW3CCaps = Boolean(capabilities.platformName &&
capabilities.browserVersion &&

@@ -21,33 +23,38 @@ (capabilities.platformVersion || Object.prototype.hasOwnProperty.call(capabilities, 'setWindowRect')));

exports.isW3C = isW3C;
function isChrome(caps) {
if (!caps) {
function isChrome(capabilities) {
if (!capabilities) {
return false;
}
return (Boolean(caps.chrome) ||
Boolean(caps['goog:chromeOptions']));
return Boolean(capabilities.chrome || capabilities['goog:chromeOptions']);
}
function isMobile(caps) {
if (!caps) {
function isMobile(capabilities) {
if (!capabilities) {
return false;
}
const browserName = (caps.browserName || '').toLowerCase();
return Boolean(Object.keys(caps).find((cap) => MOBILE_CAPABILITIES.includes(cap)) ||
caps.browserName === '' ||
const browserName = (capabilities.browserName || '').toLowerCase();
return Boolean(Object.keys(capabilities).find((cap) => MOBILE_CAPABILITIES.includes(cap)) ||
capabilities.browserName === '' ||
MOBILE_BROWSER_NAMES.includes(browserName));
}
function isIOS(caps) {
if (!caps) {
function isIOS(capabilities) {
if (!capabilities) {
return false;
}
return Boolean((caps.platformName && caps.platformName.match(/iOS/i)) ||
(caps.deviceName && caps.deviceName.match(/(iPad|iPhone)/i)));
return Boolean((capabilities.platformName && capabilities.platformName.match(/iOS/i)) ||
(capabilities.deviceName && capabilities.deviceName.match(/(iPad|iPhone)/i)));
}
function isAndroid(caps) {
if (!caps) {
function isAndroid(capabilities) {
if (!capabilities) {
return false;
}
return Boolean((caps.platformName && caps.platformName.match(/Android/i)) ||
(caps.browserName && caps.browserName.match(/Android/i)));
return Boolean((capabilities.platformName && capabilities.platformName.match(/Android/i)) ||
(capabilities.browserName && capabilities.browserName.match(/Android/i)));
}
function isSauce(caps) {
function isSauce(capabilities) {
if (!capabilities) {
return false;
}
const caps = capabilities.alwaysMatch
? capabilities.alwaysMatch
: capabilities;
return Boolean(caps.extendedDebugging ||

@@ -57,10 +64,12 @@ (caps['sauce:options'] &&

}
function isSeleniumStandalone(caps) {
if (!caps) {
function isSeleniumStandalone(capabilities) {
if (!capabilities) {
return false;
}
return Boolean(caps['webdriver.remote.sessionid']);
return Boolean(capabilities['webdriver.remote.sessionid']);
}
function capabilitiesEnvironmentDetector(capabilities, automationProtocol) {
return automationProtocol === 'devtools' ? devtoolsEnvironmentDetector(capabilities) : webdriverEnvironmentDetector(capabilities);
return automationProtocol === 'devtools'
? devtoolsEnvironmentDetector(capabilities)
: webdriverEnvironmentDetector(capabilities);
}

@@ -67,0 +76,0 @@ exports.capabilitiesEnvironmentDetector = capabilitiesEnvironmentDetector;

@@ -1,26 +0,9 @@

import initialisePlugin from "./initialisePlugin";
import { initialiseLauncherService } from "./initialiseServices";
import { initialiseWorkerService } from "./initialiseServices";
import { isFunctionAsync } from "./utils";
import { transformCommandLogResult } from "./utils";
import webdriverMonad from "./monad";
import { commandCallStructure } from "./utils";
import { isValidParameter } from "./utils";
import { getArgumentType } from "./utils";
import { safeRequire } from "./utils";
import { canAccess } from "./utils";
import { sleep } from "./utils";
import { wrapCommand } from "./shim";
import { executeSync } from "./shim";
import { executeAsync } from "./shim";
import { runFnInFiberContext } from "./shim";
import { runTestInFiberContext } from "./test-framework";
import { testFnWrapper } from "./test-framework";
import { executeHooksWithArgs } from "./shim";
import { hasWdioSyncSupport } from "./shim";
import { isW3C } from "./envDetector";
import { sessionEnvironmentDetector } from "./envDetector";
import { capabilitiesEnvironmentDetector } from "./envDetector";
import { devtoolsEnvironmentDetector } from "./envDetector";
import initialisePlugin from './initialisePlugin';
import { initialiseWorkerService, initialiseLauncherService } from './initialiseServices';
import webdriverMonad from './monad';
import { commandCallStructure, isValidParameter, getArgumentType, safeRequire, isFunctionAsync, transformCommandLogResult, canAccess, sleep } from './utils';
import { wrapCommand, runFnInFiberContext, executeHooksWithArgs, hasWdioSyncSupport, executeSync, executeAsync } from './shim';
import { testFnWrapper, runTestInFiberContext } from './test-framework';
import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector';
export { initialisePlugin, initialiseLauncherService, initialiseWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeRequire, canAccess, sleep, wrapCommand, executeSync, executeAsync, runFnInFiberContext, runTestInFiberContext, testFnWrapper, executeHooksWithArgs, hasWdioSyncSupport, isW3C, sessionEnvironmentDetector, capabilitiesEnvironmentDetector, devtoolsEnvironmentDetector };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,3 @@

export default function initialisePlugin(name: any, type: any): object;
/// <reference types="webdriverio/webdriverio-core" />
export default function initialisePlugin(name: string, type?: string): WebdriverIO.ServiceClass;
//# sourceMappingURL=initialisePlugin.d.ts.map

@@ -11,4 +11,9 @@ "use strict";

const service = utils_1.safeRequire(name);
return service;
if (service) {
return service;
}
}
if (typeof type !== 'string') {
throw new Error('No plugin type provided');
}
const scopedPlugin = utils_1.safeRequire(`@wdio/${name.toLowerCase()}-${type}`);

@@ -15,0 +20,0 @@ if (scopedPlugin) {

@@ -1,3 +0,8 @@

export function initialiseLauncherService(config: Object, caps: Object[]): Object;
export function initialiseWorkerService(config: Object, caps: Object, ignoredWorkerServices?: [any]): Object[];
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriver" />
export declare function initialiseLauncherService(config: WebdriverIO.Config, caps: WebDriver.DesiredCapabilities): {
ignoredWorkerServices: string[];
launcherServices: WebdriverIO.ServiceInstance[];
};
export declare function initialiseWorkerService(config: WebdriverIO.Config, caps: WebDriver.DesiredCapabilities, ignoredWorkerServices?: string[]): WebdriverIO.ServiceInstance[];
//# sourceMappingURL=initialiseServices.d.ts.map

@@ -42,6 +42,9 @@ "use strict";

}
const Launcher = service.launcher || service;
if (typeof Launcher === 'function') {
const Launcher = service.launcher;
if (typeof Launcher === 'function' && serviceName) {
launcherServices.push(new Launcher(serviceConfig, caps, config));
}
if (typeof service === 'function' && !serviceName) {
launcherServices.push(new service(serviceConfig, caps, config));
}
if (serviceName &&

@@ -74,3 +77,3 @@ typeof service.default !== 'function' &&

}
}).filter(Boolean);
}).filter((service) => Boolean(service));
}

@@ -77,0 +80,0 @@ catch (err) {

@@ -1,5 +0,22 @@

export default function WebDriver(options: any, modifier: any, propertiesObject?: {}): {
(sessionId: any, commandWrapper: any): any;
lift(name: string, func: Function, proto: Object, origCommand: Function): void;
/// <reference types="webdriver" />
/// <reference types="webdriverio/webdriverio-core" />
interface PropertiesObject {
scope?: string;
commandList?: {
value: string[];
};
options?: {
value: Record<string, any>;
};
requestedCapabilities?: {
value?: Record<string, any>;
};
puppeteer?: any;
[key: string]: any;
}
export default function WebDriver(options: WebDriver.Options | WebdriverIO.Config, modifier?: Function, propertiesObject?: PropertiesObject): {
(this: void, sessionId: string, commandWrapper?: Function | undefined): any;
lift(name: string, func: Function, proto: Record<string, any>, origCommand?: Function | undefined): void;
};
export {};
//# sourceMappingURL=monad.d.ts.map

@@ -10,7 +10,7 @@ "use strict";

const SCOPE_TYPES = {
'browser': function Browser() { },
'element': function Element() { }
browser: function Browser() { },
element: function Element() { }
};
function WebDriver(options, modifier, propertiesObject = {}) {
const scopeType = SCOPE_TYPES[propertiesObject.scope] || SCOPE_TYPES['browser'];
const scopeType = SCOPE_TYPES[propertiesObject.scope || 'browser'];
delete propertiesObject.scope;

@@ -17,0 +17,0 @@ const prototype = Object.create(scopeType.prototype);

@@ -1,18 +0,14 @@

export function executeHooksWithArgs(hooks: any, args: any): Promise<[any, any, any, any, any, any, any, any, any, any]>;
export function runFnInFiberContext(fn: any): (...args: any[]) => Promise<any>;
export function wrapCommand(commandName: any, fn: any): (...args: any[]) => Promise<any>;
export let hasWdioSyncSupport: boolean;
export let executeSync: typeof executeSyncFn;
export function executeAsync(fn: Function, retries: object, args?: any[]): Promise<any>;
export class executeAsync {
constructor(fn: Function, retries: object, args?: any[]);
wdioRetries: any;
declare let hasWdioSyncSupport: boolean;
declare let runSync: (this: unknown, fn: Function, repeatTest: any, args: unknown[]) => (resolve: Function, reject: Function) => unknown;
interface Retries {
limit: number;
attempts: number;
}
export let runSync: any;
declare function executeSyncFn(fn: Function, retries: number, args?: any[]): Promise<any>;
declare class executeSyncFn {
constructor(fn: Function, retries: number, args?: any[]);
wdioRetries: any;
}
export {};
declare let executeHooksWithArgs: <T>(hooks?: Function | Function[], args?: any | any[]) => Promise<(Error | T)[]>;
declare let runFnInFiberContext: (fn: Function) => (this: any, ...args: any[]) => Promise<any>;
declare let wrapCommand: <T>(commandName: string, fn: Function) => (...args: any) => Promise<T>;
declare function executeSyncFn(this: any, fn: Function, retries: Retries, args?: any[]): Promise<unknown>;
declare function executeAsync(this: any, fn: Function, retries: Retries, args?: any[]): Promise<unknown>;
declare let executeSync: typeof executeSyncFn;
export { executeHooksWithArgs, runFnInFiberContext, wrapCommand, hasWdioSyncSupport, executeSync, executeAsync, runSync };
//# sourceMappingURL=shim.d.ts.map

@@ -12,5 +12,5 @@ "use strict";

exports.hasWdioSyncSupport = hasWdioSyncSupport;
let runSync = null;
let runSync;
exports.runSync = runSync;
let executeHooksWithArgs = async function executeHooksWithArgsShim(hooks, args) {
let executeHooksWithArgs = async function executeHooksWithArgsShim(hooks = [], args = []) {
if (!Array.isArray(hooks)) {

@@ -22,3 +22,3 @@ hooks = [hooks];

}
hooks = hooks.map((hook) => new Promise((resolve) => {
const hooksPromises = hooks.map((hook) => new Promise((resolve) => {
let result;

@@ -40,3 +40,3 @@ try {

}));
return Promise.all(hooks);
return Promise.all(hooksPromises);
};

@@ -43,0 +43,0 @@ exports.executeHooksWithArgs = executeHooksWithArgs;

@@ -1,2 +0,2 @@

export function logHookError(hookName: string, hookResults: any[] | undefined, cid: string): void;
export declare const logHookError: (hookName: string, hookResults: any[] | undefined, cid: string) => void;
//# sourceMappingURL=errorHandler.d.ts.map

@@ -1,4 +0,4 @@

import { testFnWrapper } from "./testFnWrapper";
import { runTestInFiberContext } from "./testInterfaceWrapper";
import { testFnWrapper } from './testFnWrapper';
import { runTestInFiberContext } from './testInterfaceWrapper';
export { testFnWrapper, runTestInFiberContext };
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,4 @@

export function testFnWrapper(...args: any[]): any;
export function testFrameworkFnWrapper({ executeHooksWithArgs, executeAsync, runSync }: object, type: string, { specFn, specFnArgs }: object, { beforeFn, beforeFnArgs }: object, { afterFn, afterFnArgs }: object, cid: string, repeatTest?: number): any;
import type { WrapperMethods, SpecFunction, BeforeHookParam, AfterHookParam } from './types';
export declare const testFnWrapper: (this: unknown, args_0: string, args_1: SpecFunction, args_2: BeforeHookParam<unknown>, args_3: AfterHookParam<unknown>, args_4: string, args_5: number) => Promise<unknown>;
export declare const testFrameworkFnWrapper: (this: unknown, { executeHooksWithArgs, executeAsync, runSync }: WrapperMethods, type: string, { specFn, specFnArgs }: SpecFunction, { beforeFn, beforeFnArgs }: BeforeHookParam<unknown>, { afterFn, afterFnArgs }: AfterHookParam<unknown>, cid: string, repeatTest?: number) => Promise<unknown>;
//# sourceMappingURL=testFnWrapper.d.ts.map

@@ -1,5 +0,7 @@

export function runHook(hookFn: Function, origFn: Function, beforeFn: Function, beforeFnArgs: Function, afterFn: Function, afterFnArgs: any, cid: string, repeatTest: number): Function;
export function runSpec(specTitle: string, specFn: Function, origFn: Function, beforeFn: Function, beforeFnArgs: Function, afterFn: Function, afterFnArgs: Function, cid: string, repeatTest: number): Function;
export function wrapTestFunction(origFn: Function, isSpec: any, beforeFn: Function, beforeArgsFn: any, afterFn: Function, afterArgsFn: Function, cid: string): Function;
export function runTestInFiberContext(isSpec: any, beforeFn: Function, beforeArgsFn: any, afterFn: Function, afterArgsFn: Function, fnName: string, cid: string, scope?: Object): void;
/// <reference types="node" />
import type { HookFnArgs, SpecArguments } from './types';
export declare const runHook: (this: unknown, hookFn: Function, origFn: Function, beforeFn: Function, beforeFnArgs: HookFnArgs<unknown>, afterFn: Function, afterFnArgs: HookFnArgs<unknown>, cid: string, repeatTest: number) => any;
export declare const runSpec: (this: unknown, specTitle: string, specFn: Function, origFn: Function, beforeFn: Function, beforeFnArgs: HookFnArgs<unknown>, afterFn: Function, afterFnArgs: HookFnArgs<unknown>, cid: string, repeatTest: number) => any;
export declare const wrapTestFunction: (this: unknown, origFn: Function, isSpec: boolean, beforeFn: Function, beforeArgsFn: HookFnArgs<unknown>, afterFn: Function, afterArgsFn: HookFnArgs<unknown>, cid: string) => (...specArguments: SpecArguments) => any;
export declare const runTestInFiberContext: (this: unknown, isSpec: boolean, beforeFn: Function, beforeArgsFn: HookFnArgs<unknown>, afterFn: Function, afterArgsFn: HookFnArgs<unknown>, fnName: string, cid: string, scope?: NodeJS.Global) => void;
//# sourceMappingURL=testInterfaceWrapper.d.ts.map

@@ -9,3 +9,12 @@ "use strict";

return origFn(function (...hookFnArgs) {
return testFnWrapper_1.testFnWrapper.call(this, 'Hook', { specFn: hookFn, specFnArgs: utils_1.filterSpecArgs(hookFnArgs) }, { beforeFn, beforeFnArgs }, { afterFn, afterFnArgs }, cid, repeatTest);
return testFnWrapper_1.testFnWrapper.call(this, 'Hook', {
specFn: hookFn,
specFnArgs: utils_1.filterSpecArgs(hookFnArgs)
}, {
beforeFn,
beforeFnArgs
}, {
afterFn,
afterFnArgs
}, cid, repeatTest);
});

@@ -15,3 +24,12 @@ };

return origFn(specTitle, function (...specFnArgs) {
return testFnWrapper_1.testFnWrapper.call(this, 'Test', { specFn, specFnArgs: utils_1.filterSpecArgs(specFnArgs) }, { beforeFn, beforeFnArgs }, { afterFn, afterFnArgs }, cid, repeatTest);
return testFnWrapper_1.testFnWrapper.call(this, 'Test', {
specFn,
specFnArgs: utils_1.filterSpecArgs(specFnArgs)
}, {
beforeFn,
beforeFnArgs
}, {
afterFn,
afterFnArgs
}, cid, repeatTest);
});

@@ -26,4 +44,5 @@ };

if (isSpec) {
if (specFn)
if (specFn) {
return exports.runSpec(specTitle, specFn, origFn, beforeFn, beforeArgsFn, afterFn, afterArgsFn, cid, retryCnt);
}
return origFn(specTitle);

@@ -30,0 +49,0 @@ }

@@ -1,12 +0,22 @@

export function overwriteElementCommands(propertiesObject: object): void;
export function commandCallStructure(commandName: any, args: any): string;
export function transformCommandLogResult(result: Object): Object;
export function isValidParameter(arg: any, expectedType: Object): boolean;
export function getArgumentType(arg: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null";
export function safeRequire(name: string): object;
export function isFunctionAsync(fn: Function): boolean;
export function filterSpecArgs(args: any): any;
export function isBase64(str: string): boolean;
export function canAccess(file: string): boolean;
export function sleep(ms?: number): Promise<any>;
/// <reference types="webdriverio/webdriverio-core" />
export declare function overwriteElementCommands(propertiesObject: {
'__elementOverrides__'?: {
value: any;
};
[key: string]: any;
}): void;
export declare function commandCallStructure(commandName: string, args: any[]): string;
export declare function transformCommandLogResult(result: {
file?: string;
}): "\"<Screenshot[base64]>\"" | {
file?: string | undefined;
};
export declare function isValidParameter(arg: any, expectedType: string): boolean;
export declare function getArgumentType(arg: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null";
export declare function safeRequire(name: string): WebdriverIO.ServiceClass | null;
export declare function isFunctionAsync(fn: Function): boolean;
export declare function filterSpecArgs(args: any[]): any[];
export declare function isBase64(str: string): boolean;
export declare const canAccess: (file: string) => boolean;
export declare const sleep: (ms?: number) => Promise<unknown>;
//# sourceMappingURL=utils.d.ts.map

@@ -108,10 +108,11 @@ "use strict";

function safeRequire(name) {
var _a, _b, _c;
let requirePath;
try {
const localNodeModules = path_1.default.join(process.cwd(), '/node_modules');
if (!require.main.paths.includes(localNodeModules)) {
require.main.paths.push(localNodeModules);
if (!((_a = require === null || require === void 0 ? void 0 : require.main) === null || _a === void 0 ? void 0 : _a.paths.includes(localNodeModules))) {
(_b = require === null || require === void 0 ? void 0 : require.main) === null || _b === void 0 ? void 0 : _b.paths.push(localNodeModules);
const requireOpts = process.env.JEST_WORKER_ID
? {}
: { paths: require.main.paths };
: { paths: (_c = require === null || require === void 0 ? void 0 : require.main) === null || _c === void 0 ? void 0 : _c.paths };
requirePath = require.resolve(name, requireOpts);

@@ -144,4 +145,3 @@ }

var notBase64 = new RegExp('[^A-Z0-9+\\/=]', 'i');
const isString = (typeof str === 'string' || str instanceof String);
if (!isString) {
if (typeof str !== 'string') {
throw new Error('Expected string but received invalid type.');

@@ -148,0 +148,0 @@ }

{
"name": "@wdio/utils",
"version": "6.6.3",
"version": "6.7.0",
"description": "A WDIO helper utility to provide several utility functions used across the project.",

@@ -31,3 +31,4 @@ "author": "Christian Bromann <christian@saucelabs.com>",

},
"gitHead": "f9b6fdbb63334fbb9942c14b236d9dc4e40d684b"
"types": "./build/index.d.ts",
"gitHead": "5b130b13e3a39a6800bf38e5cc398bf3af420117"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc