added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
WDIO Configurations Utility
===========================
> A helper utility to parse and validate WebdriverIO options
+5
View File
@@ -0,0 +1,5 @@
import type { ConfigOptions, Hooks } from './types';
export declare const DEFAULT_CONFIGS: () => ConfigOptions;
export declare const SUPPORTED_HOOKS: (keyof Hooks)[];
export declare const SUPPORTED_FILE_EXTENSIONS: string[];
//# sourceMappingURL=constants.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMnD,eAAO,MAAM,eAAe,EAAE,MAAM,aAiElC,CAAA;AAEF,eAAO,MAAM,eAAe,EAAE,CAAC,MAAM,KAAK,CAAC,EAK1C,CAAA;AAED,eAAO,MAAM,yBAAyB,UAErC,CAAA"}
+67
View File
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SUPPORTED_FILE_EXTENSIONS = exports.SUPPORTED_HOOKS = exports.DEFAULT_CONFIGS = void 0;
const DEFAULT_TIMEOUT = 10000;
exports.DEFAULT_CONFIGS = () => ({
specs: [],
suites: {},
exclude: [],
outputDir: undefined,
logLevel: 'info',
logLevels: {},
excludeDriverLogs: [],
bail: 0,
waitforInterval: 500,
waitforTimeout: 5000,
framework: 'mocha',
reporters: [],
services: [],
maxInstances: 100,
maxInstancesPerCapability: 100,
filesToWatch: [],
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
execArgv: [],
runnerEnv: {},
runner: 'local',
mochaOpts: {
timeout: DEFAULT_TIMEOUT
},
jasmineNodeOpts: {
defaultTimeoutInterval: DEFAULT_TIMEOUT
},
cucumberOpts: {
timeout: DEFAULT_TIMEOUT
},
onPrepare: [],
onWorkerStart: [],
before: [],
beforeSession: [],
beforeSuite: [],
beforeHook: [],
beforeTest: [],
beforeCommand: [],
afterCommand: [],
afterTest: [],
afterHook: [],
afterSuite: [],
afterSession: [],
after: [],
onComplete: [],
onReload: [],
beforeFeature: [],
beforeScenario: [],
beforeStep: [],
afterStep: [],
afterScenario: [],
afterFeature: [],
});
exports.SUPPORTED_HOOKS = [
'before', 'beforeSession', 'beforeSuite', 'beforeHook', 'beforeTest', 'beforeCommand',
'afterCommand', 'afterTest', 'afterHook', 'afterSuite', 'afterSession', 'after',
'beforeFeature', 'beforeScenario', 'beforeStep', 'afterStep', 'afterScenario', 'afterFeature',
'onReload', 'onPrepare', 'onWorkerStart', 'onComplete'
];
exports.SUPPORTED_FILE_EXTENSIONS = [
'.js', '.mjs', '.es6', '.ts', '.feature', '.coffee', '.cjs'
];
+7
View File
@@ -0,0 +1,7 @@
import ConfigParser from './lib/ConfigParser';
import { validateConfig, getSauceEndpoint, detectBackend, isCloudCapability } from './utils';
import { DEFAULT_CONFIGS } from './constants';
import { ConfigOptions } from './types';
export * from './types';
export { validateConfig, getSauceEndpoint, detectBackend, isCloudCapability, ConfigParser, ConfigOptions, DEFAULT_CONFIGS };
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,cAAc,SAAS,CAAA;AACvB,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EAKb,eAAe,EAClB,CAAA"}
+26
View File
@@ -0,0 +1,26 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CONFIGS = exports.ConfigParser = exports.isCloudCapability = exports.detectBackend = exports.getSauceEndpoint = exports.validateConfig = void 0;
const ConfigParser_1 = __importDefault(require("./lib/ConfigParser"));
exports.ConfigParser = ConfigParser_1.default;
const utils_1 = require("./utils");
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return utils_1.validateConfig; } });
Object.defineProperty(exports, "getSauceEndpoint", { enumerable: true, get: function () { return utils_1.getSauceEndpoint; } });
Object.defineProperty(exports, "detectBackend", { enumerable: true, get: function () { return utils_1.detectBackend; } });
Object.defineProperty(exports, "isCloudCapability", { enumerable: true, get: function () { return utils_1.isCloudCapability; } });
const constants_1 = require("./constants");
Object.defineProperty(exports, "DEFAULT_CONFIGS", { enumerable: true, get: function () { return constants_1.DEFAULT_CONFIGS; } });
__exportStar(require("./types"), exports);
+23
View File
@@ -0,0 +1,23 @@
/// <reference types="webdriver" />
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="webdriverio" />
/// <reference types="@wdio/cucumber-framework" />
import type { ConfigOptions, Hooks } from '../types';
interface MergeConfig extends Omit<Partial<ConfigOptions>, 'specs' | 'exclude'> {
specs?: string | string[];
exclude?: string | string[];
}
export default class ConfigParser {
private _config;
private _capabilities;
addConfigFile(filename: string): void;
merge(object?: MergeConfig): void;
addService(service: Hooks): void;
getSpecs(capSpecs?: string[], capExclude?: string[]): string[];
setFilePathToFilterOptions(cliArgFileList: string[], config: string[]): string[];
getConfig(): Required<ConfigOptions>;
getCapabilities(i?: number): WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities | import("webdriverio").MultiRemoteCapabilities | (WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities)[];
static getFilePaths(patterns: string[], omitWarnings?: boolean): string[];
}
export {};
//# sourceMappingURL=ConfigParser.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ConfigParser.d.ts","sourceRoot":"","sources":["../../src/lib/ConfigParser.ts"],"names":[],"mappings":";;;;AAWA,OAAO,KAAK,EAAgB,aAAa,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAKlE,UAAU,WAAY,SAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,aAAa,CAAoB;IAMzC,aAAa,CAAE,QAAQ,EAAE,MAAM;IAuD/B,KAAK,CAAE,MAAM,GAAE,WAAgB;IA6C/B,UAAU,CAAE,OAAO,EAAE,KAAK;IAkC1B,QAAQ,CAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE;IA8DpD,0BAA0B,CAAE,cAAc,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IA2BtE,SAAS;IAOT,eAAe,CAAE,CAAC,CAAC,EAAE,MAAM;IAc3B,MAAM,CAAC,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,OAAO;CAgClE"}
+190
View File
@@ -0,0 +1,190 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const glob_1 = __importDefault(require("glob"));
const deepmerge_1 = __importDefault(require("deepmerge"));
const logger_1 = __importDefault(require("@wdio/logger"));
const utils_1 = require("../utils");
const constants_1 = require("../constants");
const log = logger_1.default('@wdio/config:ConfigParser');
const MERGE_OPTIONS = { clone: false };
class ConfigParser {
constructor() {
this._config = constants_1.DEFAULT_CONFIGS();
this._capabilities = [];
}
addConfigFile(filename) {
if (typeof filename !== 'string') {
throw new Error('addConfigFile requires filepath');
}
const filePath = path_1.default.resolve(process.cwd(), filename);
try {
utils_1.loadTypeScriptCompiler();
const fileConfig = deepmerge_1.default(require(filePath).config, {}, MERGE_OPTIONS);
const defaultTo = Array.isArray(this._capabilities) ? [] : {};
this._capabilities = deepmerge_1.default(this._capabilities, fileConfig.capabilities || defaultTo, MERGE_OPTIONS);
delete fileConfig.capabilities;
this.addService(fileConfig);
for (let hookName of constants_1.SUPPORTED_HOOKS) {
delete fileConfig[hookName];
}
this._config = deepmerge_1.default(this._config, fileConfig, MERGE_OPTIONS);
this._config = deepmerge_1.default(utils_1.detectBackend(this._config), this._config, MERGE_OPTIONS);
delete this._config.watch;
}
catch (e) {
log.error(`Failed loading configuration file: ${filePath}:`, e.message);
throw e;
}
}
merge(object = {}) {
const spec = Array.isArray(object.spec) ? object.spec : [];
const exclude = Array.isArray(object.exclude) ? object.exclude : [];
this._config = deepmerge_1.default(this._config, object, MERGE_OPTIONS);
if (object.specs && object.specs.length > 0) {
this._config.specs = object.specs;
}
else if (object.exclude && object.exclude.length > 0) {
this._config.exclude = object.exclude;
}
this._capabilities = utils_1.validObjectOrArray(this._config.capabilities) ? this._config.capabilities : this._capabilities;
if (this._config.spec && utils_1.isCucumberFeatureWithLineNumber(this._config.spec)) {
this._config.cucumberFeaturesWithLineNumbers = Array.isArray(this._config.spec) ? [...this._config.spec] : [this._config.spec];
}
if (spec.length > 0) {
this._config.specs = this.setFilePathToFilterOptions(spec, this._config.specs);
}
if (exclude.length > 0) {
this._config.exclude = this.setFilePathToFilterOptions(exclude, this._config.exclude);
}
this._config = deepmerge_1.default(utils_1.detectBackend(this._config), this._config, MERGE_OPTIONS);
}
addService(service) {
const addHook = (hookName, hook) => {
const existingHooks = this._config[hookName];
if (!existingHooks) {
this._config[hookName] = hook.bind(service);
}
else if (typeof existingHooks === 'function') {
this._config[hookName] = [existingHooks, hook.bind(service)];
}
else {
this._config[hookName] = [...existingHooks, hook.bind(service)];
}
};
for (const hookName of constants_1.SUPPORTED_HOOKS) {
const hooksToBeAdded = service[hookName];
if (!hooksToBeAdded) {
continue;
}
if (typeof hooksToBeAdded === 'function') {
addHook(hookName, hooksToBeAdded);
}
else if (Array.isArray(hooksToBeAdded)) {
for (const hookToAdd of hooksToBeAdded) {
if (typeof hookToAdd === 'function') {
addHook(hookName, hookToAdd);
}
}
}
}
}
getSpecs(capSpecs, capExclude) {
var _a;
let specs = ConfigParser.getFilePaths(this._config.specs);
let spec = Array.isArray(this._config.spec) ? this._config.spec : [];
let exclude = ConfigParser.getFilePaths(this._config.exclude);
let suites = Array.isArray(this._config.suite) ? this._config.suite : [];
if (suites.length > 0) {
let suiteSpecs = [];
for (let suiteName of suites) {
let suite = (_a = this._config.suites) === null || _a === void 0 ? void 0 : _a[suiteName];
if (!suite) {
log.warn(`No suite was found with name "${suiteName}"`);
}
if (Array.isArray(suite)) {
suiteSpecs = suiteSpecs.concat(ConfigParser.getFilePaths(suite));
}
}
if (suiteSpecs.length === 0) {
throw new Error(`The suite(s) "${suites.join('", "')}" you specified don't exist ` +
'in your config file or doesn\'t contain any files!');
}
let tmpSpecs = spec.length > 0 ? [...specs, ...suiteSpecs] : suiteSpecs;
if (Array.isArray(capSpecs)) {
tmpSpecs = ConfigParser.getFilePaths(capSpecs);
}
if (Array.isArray(capExclude)) {
exclude = ConfigParser.getFilePaths(capExclude);
}
specs = [...new Set(tmpSpecs)];
return specs.filter(spec => !exclude.includes(spec));
}
if (Array.isArray(capSpecs)) {
specs = ConfigParser.getFilePaths(capSpecs);
}
if (Array.isArray(capExclude)) {
exclude = ConfigParser.getFilePaths(capExclude);
}
return specs.filter(spec => !exclude.includes(spec));
}
setFilePathToFilterOptions(cliArgFileList, config) {
const filesToFilter = new Set();
const fileList = ConfigParser.getFilePaths(config);
cliArgFileList.forEach(filteredFile => {
filteredFile = utils_1.removeLineNumbers(filteredFile);
let globMatchedFiles = ConfigParser.getFilePaths(glob_1.default.sync(filteredFile));
if (fs_1.default.existsSync(filteredFile) && fs_1.default.lstatSync(filteredFile).isFile()) {
filesToFilter.add(path_1.default.resolve(process.cwd(), filteredFile));
}
else if (globMatchedFiles.length) {
globMatchedFiles.forEach(file => filesToFilter.add(file));
}
else {
fileList.forEach(file => {
if (file.match(filteredFile)) {
filesToFilter.add(file);
}
});
}
});
if (filesToFilter.size === 0) {
throw new Error(`spec file(s) ${cliArgFileList.join(', ')} not found`);
}
return [...filesToFilter];
}
getConfig() {
return this._config;
}
getCapabilities(i) {
if (typeof i === 'number' && Array.isArray(this._capabilities) && this._capabilities[i]) {
return this._capabilities[i];
}
return this._capabilities;
}
static getFilePaths(patterns, omitWarnings) {
let files = [];
if (typeof patterns === 'string') {
patterns = [patterns];
}
if (!Array.isArray(patterns)) {
throw new Error('specs or exclude property should be an array of strings');
}
patterns = patterns.map(pattern => utils_1.removeLineNumbers(pattern));
for (let pattern of patterns) {
let filenames = glob_1.default.sync(pattern);
filenames = filenames.filter((filename) => constants_1.SUPPORTED_FILE_EXTENSIONS.find((ext) => filename.endsWith(ext)));
filenames = filenames.map(filename => path_1.default.isAbsolute(filename) ? path_1.default.normalize(filename) : path_1.default.resolve(process.cwd(), filename));
if (filenames.length === 0 && !omitWarnings) {
log.warn('pattern', pattern, 'did not match any file');
}
files = deepmerge_1.default(files, filenames, MERGE_OPTIONS);
}
return files;
}
}
exports.default = ConfigParser;
+32
View File
@@ -0,0 +1,32 @@
/// <reference types="webdriverio/webdriverio-core" />
/// <reference types="@wdio/cucumber-framework" />
/// <reference types="webdriver" />
export declare type Hooks = {
[k in keyof WebdriverIO.HookFunctions]: WebdriverIO.HookFunctions[k] | NonNullable<WebdriverIO.HookFunctions[k]>[];
};
export declare type Capabilities = (WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities)[] | WebdriverIO.MultiRemoteCapabilities;
export declare type Capability = WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities | WebdriverIO.MultiRemoteCapabilities;
export interface ConfigOptions extends Omit<WebdriverIO.Config, 'capabilities' | keyof WebdriverIO.Hooks>, Hooks {
automationProtocol?: 'webdriver' | 'devtools' | './protocol-stub';
spec?: string[];
suite?: string[];
capabilities?: Capabilities;
specFileRetryAttempts?: number;
cucumberFeaturesWithLineNumbers?: string[];
specFileRetriesDeferred?: boolean;
specFileRetries?: number;
maxInstances?: number;
}
export interface SingleConfigOption extends Omit<ConfigOptions, 'capabilities'> {
capabilities: Capability;
}
export declare type DefaultOptions<T> = {
[k in keyof T]?: {
type: 'string' | 'number' | 'object' | 'boolean' | 'function';
default?: T[k];
required?: boolean;
validate?: (option: T[k]) => void;
match?: RegExp;
};
};
//# sourceMappingURL=types.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AACA,oBAAY,KAAK,GAAG;KACf,CAAC,IAAI,MAAM,WAAW,CAAC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;CACrH,CAAA;AAED,oBAAY,YAAY,GAAG,CAAC,SAAS,CAAC,mBAAmB,GAAG,SAAS,CAAC,eAAe,CAAC,EAAE,GAAG,WAAW,CAAC,uBAAuB,CAAC;AAC/H,oBAAY,UAAU,GAAG,SAAS,CAAC,mBAAmB,GAAG,SAAS,CAAC,eAAe,GAAG,WAAW,CAAC,uBAAuB,CAAC;AAEzH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK;IAC5G,kBAAkB,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAA;IACjE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,+BAA+B,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1C,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;IAC3E,YAAY,EAAE,UAAU,CAAA;CAC3B;AAED,oBAAY,cAAc,CAAC,CAAC,IAAI;KAC3B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;QACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAA;QAC7D,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;QACd,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;QACjC,KAAK,CAAC,EAAE,MAAM,CAAA;KACjB;CACJ,CAAA"}
+2
View File
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
+38
View File
@@ -0,0 +1,38 @@
/// <reference types="webdriver" />
/// <reference types="webdriverio/webdriverio-core" />
import type { DefaultOptions, Capabilities } from './types';
declare const REGION_MAPPING: {
us: string;
eu: string;
'eu-central-1': string;
'us-east-1': string;
};
export declare const validObjectOrArray: (object: any) => object is object | any[];
export declare function getSauceEndpoint(region: keyof typeof REGION_MAPPING, { isRDC, isVisual }?: {
isRDC?: boolean;
isVisual?: boolean;
}): string;
export declare function removeLineNumbers(filePath: string): string;
export declare function isCucumberFeatureWithLineNumber(spec: string | string[]): boolean;
export declare function isCloudCapability(capabilities: WebDriver.DesiredCapabilities | WebdriverIO.MultiRemoteBrowserOptions): boolean;
interface BackendConfigurations {
port?: number;
hostname?: string;
user?: string;
key?: string;
protocol?: string;
region?: string;
headless?: boolean;
path?: string;
capabilities?: Capabilities | WebDriver.DesiredCapabilities | WebDriver.W3CCapabilities;
}
export declare function detectBackend(options?: BackendConfigurations): {
hostname: string | undefined;
port: number | undefined;
protocol: string | undefined;
path: string | undefined;
};
export declare function validateConfig<T>(defaults: DefaultOptions<T>, options: T, keysToKeep?: (keyof T)[]): T;
export declare function loadTypeScriptCompiler(): void;
export {};
//# sourceMappingURL=utils.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAU3D,QAAA,MAAM,cAAc;;;;;CAKnB,CAAA;AAED,eAAO,MAAM,kBAAkB,WAAY,GAAG,6BACoB,CAAA;AAElE,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,MAAM,OAAO,cAAc,EACnC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,UAUpE;AAQD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,UAMjD;AAOD,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,WAGtE;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,mBAAmB,GAAG,WAAW,CAAC,yBAAyB,WAGpH;AAED,UAAU,qBAAqB;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC,mBAAmB,GAAG,SAAS,CAAC,eAAe,CAAA;CAC1F;AAKD,wBAAgB,aAAa,CAAC,OAAO,GAAE,qBAA0B;;;;;EAuFhE;AAQD,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,cAAoB,KA+CxG;AAED,wBAAgB,sBAAsB,SAOrC"}
+144
View File
@@ -0,0 +1,144 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadTypeScriptCompiler = exports.validateConfig = exports.detectBackend = exports.isCloudCapability = exports.isCucumberFeatureWithLineNumber = exports.removeLineNumbers = exports.getSauceEndpoint = exports.validObjectOrArray = void 0;
const logger_1 = __importDefault(require("@wdio/logger"));
const log = logger_1.default('@wdio/config:utils');
const DEFAULT_HOSTNAME = '127.0.0.1';
const DEFAULT_PORT = 4444;
const DEFAULT_PROTOCOL = 'http';
const DEFAULT_PATH = '/';
const LEGACY_PATH = '/wd/hub';
const REGION_MAPPING = {
'us': 'us-west-1.',
'eu': 'eu-central-1.',
'eu-central-1': 'eu-central-1.',
'us-east-1': 'us-east-1.'
};
exports.validObjectOrArray = (object) => (Array.isArray(object) && object.length > 0) ||
(typeof object === 'object' && Object.keys(object).length > 0);
function getSauceEndpoint(region, { isRDC, isVisual } = {}) {
const shortRegion = REGION_MAPPING[region] ? region : 'us';
if (isRDC) {
return `${shortRegion}1.appium.testobject.com`;
}
else if (isVisual) {
return 'hub.screener.io';
}
return `ondemand.${REGION_MAPPING[shortRegion]}saucelabs.com`;
}
exports.getSauceEndpoint = getSauceEndpoint;
function removeLineNumbers(filePath) {
const matcher = filePath.match(/:\d+(:\d+$|$)/);
if (matcher) {
filePath = filePath.substring(0, matcher.index);
}
return filePath;
}
exports.removeLineNumbers = removeLineNumbers;
function isCucumberFeatureWithLineNumber(spec) {
const specs = Array.isArray(spec) ? spec : [spec];
return specs.some((s) => s.match(/:\d+(:\d+$|$)/));
}
exports.isCucumberFeatureWithLineNumber = isCucumberFeatureWithLineNumber;
function isCloudCapability(capabilities) {
const caps = capabilities.capabilities || capabilities;
return Boolean(caps && (caps['bstack:options'] || caps['sauce:options'] || caps['tb:options']));
}
exports.isCloudCapability = isCloudCapability;
function detectBackend(options = {}) {
var _a, _b;
let { port, hostname, user, key, protocol, region, headless, path, capabilities } = options;
if (typeof user === 'string' && typeof key === 'string' && key.length === 20) {
return {
protocol: protocol || 'https',
hostname: hostname || 'hub-cloud.browserstack.com',
port: port || 443,
path: path || LEGACY_PATH
};
}
if (typeof user === 'string' && typeof key === 'string' && key.length === 32) {
return {
protocol: protocol || 'https',
hostname: hostname || 'hub.testingbot.com',
port: port || 443,
path: path || LEGACY_PATH
};
}
const isRDC = Boolean(!Array.isArray(capabilities) && ((_a = capabilities) === null || _a === void 0 ? void 0 : _a.testobject_api_key));
const isVisual = Boolean(!Array.isArray(capabilities) && capabilities && ((_b = capabilities['sauce:visual']) === null || _b === void 0 ? void 0 : _b.apiKey));
if ((typeof user === 'string' && typeof key === 'string' && key.length === 36) ||
(isRDC || isVisual)) {
const sauceRegion = headless ? 'us-east-1' : region;
return {
protocol: protocol || 'https',
hostname: hostname || getSauceEndpoint(sauceRegion, { isRDC, isVisual }),
port: port || 443,
path: path || LEGACY_PATH
};
}
if ((typeof user === 'string' || typeof key === 'string') &&
!hostname) {
throw new Error('A "user" or "key" was provided but could not be connected to a ' +
'known cloud service (Sauce Labs, Browerstack or Testingbot). ' +
'Please check if given user and key properties are correct!');
}
if (hostname || port || protocol || path) {
return {
hostname: hostname || DEFAULT_HOSTNAME,
port: port || DEFAULT_PORT,
protocol: protocol || DEFAULT_PROTOCOL,
path: path || DEFAULT_PATH
};
}
return { hostname, port, protocol, path };
}
exports.detectBackend = detectBackend;
function validateConfig(defaults, options, keysToKeep = []) {
const params = {};
for (const [name, expectedOption] of Object.entries(defaults)) {
if (typeof options[name] === 'undefined' && !expectedOption.default && expectedOption.required) {
throw new Error(`Required option "${name}" is missing`);
}
if (typeof options[name] === 'undefined' && expectedOption.default) {
params[name] = expectedOption.default;
}
if (typeof options[name] !== 'undefined') {
const optValue = options[name];
if (typeof optValue !== expectedOption.type) {
throw new Error(`Expected option "${name}" to be type of ${expectedOption.type} but was ${typeof options[name]}`);
}
if (typeof expectedOption.validate === 'function') {
try {
expectedOption.validate(optValue);
}
catch (e) {
throw new Error(`Type check for option "${name}" failed: ${e.message}`);
}
}
if (typeof optValue === 'string' && expectedOption.match && !optValue.match(expectedOption.match)) {
throw new Error(`Option "${name}" doesn't match expected values: ${expectedOption.match}`);
}
params[name] = options[name];
}
}
for (const [name, option] of Object.entries(options)) {
if (keysToKeep.includes(name)) {
params[name] = option;
}
}
return params;
}
exports.validateConfig = validateConfig;
function loadTypeScriptCompiler() {
try {
require.resolve('ts-node');
require('ts-node').register({ transpileOnly: true });
}
catch (e) {
return log.debug('Couldn\'t find ts-node package, no TypeScript compiling');
}
}
exports.loadTypeScriptCompiler = loadTypeScriptCompiler;
+69
View File
@@ -0,0 +1,69 @@
{
"_args": [
[
"@wdio/config@6.12.1",
"/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror"
]
],
"_development": true,
"_from": "@wdio/config@6.12.1",
"_id": "@wdio/config@6.12.1",
"_inBundle": false,
"_integrity": "sha512-V5hTIW5FNlZ1W33smHF4Rd5BKjGW2KeYhyXDQfXHjqLCeRiirZ9fABCo9plaVQDnwWSUMWYaAaIAifV82/oJCQ==",
"_location": "/@wdio/config",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@wdio/config@6.12.1",
"name": "@wdio/config",
"escapedName": "@wdio%2fconfig",
"scope": "@wdio",
"rawSpec": "6.12.1",
"saveSpec": null,
"fetchSpec": "6.12.1"
},
"_requiredBy": [
"/devtools",
"/webdriver",
"/webdriverio"
],
"_resolved": "https://registry.npmjs.org/@wdio/config/-/config-6.12.1.tgz",
"_spec": "6.12.1",
"_where": "/home/pi/Desktop/smartMirrorTestEnvironment/MagicMirror",
"author": {
"name": "Christian Bromann",
"email": "christian@saucelabs.com"
},
"bugs": {
"url": "https://github.com/webdriverio/webdriverio/issues"
},
"dependencies": {
"@wdio/logger": "6.10.10",
"deepmerge": "^4.0.0",
"glob": "^7.1.2"
},
"description": "A helper utility to parse and validate WebdriverIO options",
"engines": {
"node": ">=10.0.0"
},
"gitHead": "063970498c9b1142482a1a035aa699c64cc8215c",
"homepage": "https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-config",
"keywords": [
"webdriver",
"wdio",
"wdio-utility"
],
"license": "MIT",
"main": "./build/index",
"name": "@wdio/config",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git://github.com/webdriverio/webdriverio.git"
},
"types": "./build/index.d.ts",
"version": "6.12.1"
}