import type { Options } from "@wdio/types"; import "dotenv/config"; import { returnBoolean } from "../helpers/parse.js"; export const config: Options.Testrunner = { runner: "local", autoCompileOpts: { autoCompile: true, tsNodeOpts: { transpileOnly: true, project: "tsconfig.json", }, }, specs: ["../features/**/*.feature"], specFileRetries: 2, specFileRetriesDelay: 3, specFileRetriesDeferred: false, capabilities: [], logLevel: "debug", bail: 0, baseUrl: "LACK_OF_BASE_URL", waitforTimeout: 45000, connectionRetryTimeout: 120000, connectionRetryCount: 3, services: [], framework: "cucumber", reporters: [ "spec", [ "allure", { outputDir: "./tests/.reports/allure-results", addConsoleLogs: true, disableWebdriverStepsReporting: true, disableWebdriverScreenshotsReporting: true, useCucumberStepReporter: true, }, ], ], cucumberOpts: { backtrace: false, requireModule: [], failAmbiguousDefinitions: true, failFast: false, format: ["pretty"], colors: true, ignoreUndefinedDefinitions: false, names: [], snippets: true, source: true, profile: [], require: ["./tests/steps-definitions/**/*.ts", "./tests/actions/**/*.ts"], // (expression) only execute the features or scenarios with tags matching the expression tags: "", // timeout for step definitions timeout: 60000, }, // // ===== // Hooks // ===== // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance // it and to build services around it. You can either apply a single function or an array of // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got // resolved to continue. /** * Gets executed once before all workers get launched. * @param {Object} config wdio configuration object * @param {Array.} 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.} capabilities list of capabilities details * @param {Array.} 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) { // }, /** * 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.} capabilities list of capabilities details * @param {Array.} 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: async function (scenario) { // }, /** * * 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: async function (world, result, context) { if (returnBoolean(process.env.RELOAD_SESSION as string)) await driver.reloadSession(); }, /** * * 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.} capabilities list of capabilities details * @param {Array.} 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.} capabilities list of capabilities details * @param {Array.} 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.} capabilities list of capabilities details * @param {} 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) { // } };