UNPKG

webdriverio-automation

Version:

WebdriverIO-Automation android ios project

60 lines (41 loc) 3.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.run = void 0; var _fs = _interopRequireDefault(require("fs")); var _path = _interopRequireDefault(require("path")); var _yargs = _interopRequireDefault(require("yargs")); var _launcher = _interopRequireDefault(require("./launcher")); var _run = require("./commands/run"); var _constants = require("./constants"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const DEFAULT_CONFIG_FILENAME = 'wdio.conf.js'; const DESCRIPTION = ['The `wdio` command allows you run and manage your WebdriverIO test suite.', 'If no command is provided it calls the `run` command by default, so:', '', '$ wdio wdio.conf.js', '', 'is the same as:', '$ wdio run wdio.conf.js', '', 'For more information, visit: https://webdriver.io/docs/clioptions.html']; const run = async () => { const argv = _yargs.default.commandDir('commands').example('$0 run wdio.conf.js --suite foobar', 'Run suite on testsuite "foobar"').example('$0 run wdio.conf.js --spec ./tests/e2e/a.js --spec ./tests/e2e/b.js', 'Run suite on specific specs').example('$0 run wdio.conf.js --spec ./tests/e2e/a.feature:5', 'Run scenario by line number').example('$0 run wdio.conf.js --spec ./tests/e2e/a.feature:5:10', 'Run scenarios by line number').example('$0 run wdio.conf.js --spec ./tests/e2e/a.feature:5:10 --spec ./test/e2e/b.feature', 'Run scenarios by line number in single feature and another complete feature').example('$0 install reporter spec', 'Install @wdio/spec-reporter').example('$0 repl chrome -u <SAUCE_USERNAME> -k <SAUCE_ACCESS_KEY>', 'Run repl in Sauce Labs cloud').updateStrings({ 'Commands:': `${DESCRIPTION.join('\n')}\n\nCommands:` }).epilogue(_constants.CLI_EPILOGUE); if (!process.argv.find(arg => arg === '--help')) { argv.options(_run.cmdArgs); } const params = _objectSpread({}, argv.argv); const supportedCommands = _fs.default.readdirSync(_path.default.join(__dirname, 'commands')).map(file => file.slice(0, -3)); if (!params._.find(param => supportedCommands.includes(param))) { const configPath = params._[0]; params.configPath = _path.default.resolve(process.cwd(), configPath || DEFAULT_CONFIG_FILENAME); return (0, _run.handler)(params).catch(async err => { const output = await new Promise(resolve => _yargs.default.parse('--help', (err, argv, output) => resolve(output))); console.error(`${output}\n\n${err.stack}`); if (!process.env.JEST_WORKER_ID) { process.exit(1); } }); } }; exports.run = run; var _default = _launcher.default; exports.default = _default;