UNPKG

@rbnx/webdriverio

Version:

webdriverio plugin for nx

72 lines 2.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeOptions = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const node_path_1 = tslib_1.__importDefault(require("node:path")); const wdio_1 = require("../../../wdio"); function normalizeOptions(tree, options, context) { const projectName = context.projectName; const projectRoot = context.projectsConfigurations.projects[context.projectName]?.root ?? ''; const configPath = (0, devkit_1.joinPathFragments)(projectRoot, 'wdio.generated.config.ts'); const baseConfigModuleName = options.wdioConfig ? 'config as wdioConfig' : 'wdioConfig'; let baseConfigPath; if (options.wdioConfig) { const isAbsolute = node_path_1.default.isAbsolute(options.wdioConfig); const parsedPath = node_path_1.default.parse(tree.exists(options.wdioConfig) || isAbsolute ? options.wdioConfig : (0, devkit_1.joinPathFragments)(projectRoot, options.wdioConfig)); const from = isAbsolute ? (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot) : projectRoot; baseConfigPath = `./${(0, devkit_1.joinPathFragments)(node_path_1.default.relative(from, parsedPath.dir), parsedPath.name)}`; } else { baseConfigPath = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectRoot), 'wdio.base.config'); } const isVerbose = context.isVerbose; if (options.browsers) { options.capabilities = (0, wdio_1.capabilitiesFilter)(options); } if (options.protocol) { options.services = options.services ?? []; if (options.protocol === 'devtools') options.services.push('devtools'); } let timeout = 60000; if (options.debug) { const MAX_SAFE_TIMEOUT = Math.pow(2, 31) - 1; timeout = MAX_SAFE_TIMEOUT; options.logLevel = 'debug'; options.maxInstances = 1; options.framework = getFrameWorkFromConfig(tree, options, projectRoot); } return { ...options, configPath, baseConfigModuleName, baseConfigPath, isVerbose, projectName, projectRoot, timeout, }; } exports.normalizeOptions = normalizeOptions; function getFrameWorkFromConfig(tree, options, projectRoot) { if (options.framework) return options.framework; if (options.wdioConfig) { const configPath = (0, devkit_1.joinPathFragments)(projectRoot, options.wdioConfig); if (tree.exists(configPath)) { const framework = (0, wdio_1.readPropertyFromConfig)(tree, configPath, 'framework').shift(); if (framework) { return framework; } } } return (0, wdio_1.readPropertyFromConfig)(tree, 'wdio.base.config.ts', 'framework').shift(); } //# sourceMappingURL=normalize-options.js.map