UNPKG

tlc-core-automation-framework-v3-wdio-v9

Version:

Background: - We are following multi-layer automation framework architecture using webdriver.io + cucumber + typescript This core framework has been implemented with generic utility functions and cucumber steps, which can be easily consumed by another fra

273 lines 15.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.config = void 0; const dotenv_1 = __importDefault(require("dotenv")); const logger_1 = __importDefault(require("./src/e2e/helpers/reporting-helpers/logger")); const chromeOptions = []; if (process.env.GITLAB) { chromeOptions.push('--headless'); chromeOptions.push('--disable-dev-shm-usage'); } const setupDeviceEmulation = () => { const tags = process.env.PLATFORM_TAG || "@desktop"; const isMobile = tags.includes('@mobile'); const isTablet = tags.includes('@tablet'); const isDesktop = tags.includes('@desktop'); logger_1.default.info(`Running tests on : ${tags.split('@')[1]}`); if (isMobile) { return { 'deviceName': 'iPhone XR' }; } else if (isTablet) { return { 'deviceName': 'iPad Air' }; } else if (isDesktop) { return undefined; } }; exports.config = { // autoCompileOpts: { // autoCompile: true, // // see https://github.com/TypeStrong/ts-node#cli-and-programmatic-options // // for all available options // tsNodeOpts: { // transpileOnly: true, // project: 'tsconfig.json' // } // }, specs: [ './src/features/**/*.feature' ], // Patterns to exclude. exclude: [ // 'path/to/excluded/files' ], // maxInstances: 10, injectGlobals: true, capabilities: [{ maxInstances: 1, browserName: 'chrome', //chrome, firefox, safari acceptInsecureCerts: true, // acceptSslCerts: true, 'wdio:enforceWebDriverClassic': true, 'goog:chromeOptions': { args: [ '--no-sandbox', '--disable-dev-shm-usage', '--window-size=1920,1080', '--ignore-certificate-errors', '--disable-web-security', '--allow-running-insecure-content', '--disable-cache', '--disable-application-cache', '--dns-prefetch-disable', '--disable-gpu', ].concat(chromeOptions), mobileEmulation: setupDeviceEmulation(), prefs: { 'profile.default_content_setting_values.geolocation': false, 'profile.password_manager_enabled': false, 'credentials_enable_service': false, 'password_manager_enabled': false } } }], logLevel: 'debug', bail: 0, baseUrl: 'https://the-internet.herokuapp.com', pageId: "", waitforTimeout: 60000, connectionRetryTimeout: 120000, connectionRetryCount: 3, framework: 'cucumber', reporters: ['spec'], cucumberOpts: { // <string[]> (file/dir) require files before executing features require: ['./src/e2e/step-definitions/**/*.ts'], // <boolean> show full backtrace for errors backtrace: false, // <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable) requireModule: [], // <boolean> invoke formatters without executing steps dryRun: false, // <boolean> abort the run on first failure failFast: false, // <boolean> hide step definition snippets for pending steps snippets: true, // <boolean> hide source uris source: true, // <boolean> fail if there are any undefined or pending steps strict: false, // <string> (expression) only execute the features or scenarios with tags matching the expression tagExpression: '', // <number> timeout for step definitions timeout: 60000, // <boolean> Enable this config to treat undefined definitions as warnings. ignoreUndefinedDefinitions: false }, /** * Gets executed once before all workers get launched. * @param {Object} config wdio configuration object * @param {Array.<Object>} capabilities list of capabilities details */ // onPrepare: function (config, capabilities) { // }, /** * Gets executed before a worker process is spawned and can be used to initialise specific service * for that worker as well as modify runtime environments in an async fashion. * @param {String} cid capability id (e.g 0-0) * @param {[type]} caps object containing capabilities for session that will be spawn in the worker * @param {[type]} specs specs to be run in the worker process * @param {[type]} args object that will be merged with the main configuration once worker is initialized * @param {[type]} execArgv list of string arguments passed to the worker process */ // onWorkerStart: function (cid, caps, specs, args, execArgv) { // }, /** * Gets executed just after a worker process has exited. * @param {String} cid capability id (e.g 0-0) * @param {Number} exitCode 0 - success, 1 - fail * @param {[type]} specs specs to be run in the worker process * @param {Number} retries number of retries used */ // onWorkerEnd: function (cid, exitCode, specs, retries) { // }, /** * Gets executed just before initialising the webdriver session and test framework. It allows you * to manipulate configurations depending on the capability or spec. * @param {Object} config wdio configuration object * @param {Array.<Object>} capabilities list of capabilities details * @param {Array.<String>} specs List of spec file paths that are to be run * @param {String} cid worker id (e.g. 0-0) */ beforeSession: function (config, capabilities, specs, cid) { // console.log(`Initializing before Session`); // dotenv.config({path: `env/common.env`}) // console.log(`Env file loaded successfully`); // console.log(`Before session ended`); }, /** * Gets executed before test execution begins. At this point you can access to all global * variables like `browser`. It is the perfect place to define custom commands. * @param {Array.<Object>} capabilities list of capabilities details * @param {Array.<String>} specs List of spec file paths that are to be run * @param {Object} browser instance of created browser/device session */ // before: function (capabilities, specs) { // }, /** * Runs before a WebdriverIO command gets executed. * @param {String} commandName hook command name * @param {Array} args arguments that command would receive */ // beforeCommand: function (commandName, args) { // }, /** * Cucumber Hooks * * Runs before a Cucumber Feature. * @param {String} uri path to feature file * @param {GherkinDocument.IFeature} feature Cucumber feature object */ // beforeFeature: function (uri, feature) { // }, /** * * Runs before a Cucumber Scenario. * @param {ITestCaseHookParameter} world world object containing information on pickle and test step * @param {Object} context Cucumber World object */ beforeScenario: function (world, context) { dotenv_1.default.config({ path: `env/common.env` }); logger_1.default.info(`Env file loaded successfully`); // browserHelper.clearBrowserStorage(); }, /** * * Runs before a Cucumber Step. * @param {Pickle.IPickleStep} step step data * @param {IPickle} scenario scenario pickle * @param {Object} context Cucumber World object */ // beforeStep: function (step, scenario, context) { // }, /** * * Runs after a Cucumber Step. * @param {Pickle.IPickleStep} step step data * @param {IPickle} scenario scenario pickle * @param {Object} result results object containing scenario results * @param {boolean} result.passed true if scenario has passed * @param {string} result.error error stack if scenario failed * @param {number} result.duration duration of scenario in milliseconds * @param {Object} context Cucumber World object */ // afterStep: function (step, scenario, result, context) { // }, /** * * Runs after a Cucumber Scenario. * @param {ITestCaseHookParameter} world world object containing information on pickle and test step * @param {Object} result results object containing scenario results * @param {boolean} result.passed true if scenario has passed * @param {string} result.error error stack if scenario failed * @param {number} result.duration duration of scenario in milliseconds * @param {Object} context Cucumber World object */ // afterScenario: function (world, result, context) { // }, /** * * Runs after a Cucumber Feature. * @param {String} uri path to feature file * @param {GherkinDocument.IFeature} feature Cucumber feature object */ // afterFeature: function (uri, feature) { // }, /** * Runs after a WebdriverIO command gets executed * @param {String} commandName hook command name * @param {Array} args arguments that command would receive * @param {Number} result 0 - command success, 1 - command error * @param {Object} error error object if any */ // afterCommand: function (commandName, args, result, error) { // }, /** * Gets executed after all tests are done. You still have access to all global variables from * the test. * @param {Number} result 0 - test pass, 1 - test fail * @param {Array.<Object>} capabilities list of capabilities details * @param {Array.<String>} specs List of spec file paths that ran */ // after: function (result, capabilities, specs) { // }, /** * Gets executed right after terminating the webdriver session. * @param {Object} config wdio configuration object * @param {Array.<Object>} capabilities list of capabilities details * @param {Array.<String>} specs List of spec file paths that ran */ // afterSession: function (config, capabilities, specs) { // }, /** * Gets executed after all workers got shut down and the process is about to exit. An error * thrown in the onComplete hook will result in the test run failing. * @param {Object} exitCode 0 - success, 1 - fail * @param {Object} config wdio configuration object * @param {Array.<Object>} capabilities list of capabilities details * @param {<Object>} results object containing test results */ // onComplete: function(exitCode, config, capabilities, results) { // }, /** * Gets executed when a refresh happens. * @param {String} oldSessionId session ID of the old session * @param {String} newSessionId session ID of the new session */ // onReload: function(oldSessionId, newSessionId) { // } }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2Rpby5jb25mLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vd2Rpby5jb25mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLG9EQUE0QjtBQUU1Qix3RkFBZ0U7QUFFaEUsTUFBTSxhQUFhLEdBQUcsRUFBRSxDQUFDO0FBRXpCLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsQ0FBQztJQUNyQixhQUFhLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBQ2pDLGFBQWEsQ0FBQyxJQUFJLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUNsRCxDQUFDO0FBRUQsTUFBTSxvQkFBb0IsR0FBRyxHQUFHLEVBQUU7SUFDOUIsTUFBTSxJQUFJLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxZ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