Advertisement
SRD75

wdio.conf.js

Nov 30th, 2022
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. const { join } = require('path')
  4.  
  5. exports.config = {
  6.     //
  7.     // ====================
  8.     // Runner Configuration
  9.     // ====================
  10.     //
  11.     //
  12.     // ==================
  13.     // Specify Test Files
  14.     // ==================
  15.     // Define which test specs should run. The pattern is relative to the directory
  16.     // from which `wdio` was called.
  17.     //
  18.     // The specs are defined as an array of spec files (optionally using wildcards
  19.     // that will be expanded). The test for each spec file will be run in a separate
  20.     // worker process. In order to have a group of spec files run in the same worker
  21.     // process simply enclose them in an array within the specs array.
  22.     //
  23.     // If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script),
  24.     // then the current working directory is where your `package.json` resides, so `wdio`
  25.     // will be called from there.
  26.     //
  27.  
  28.     specs: [
  29.  
  30.         // './test/specs/**/UK-products.spec.js',
  31.         // './test/specs/**/UK-solutions.spec.js',
  32.         // './test/specs/**/UK-resources.spec.js',
  33.         // './test/specs/**/UK-tempCategory.spec.js',
  34.         // './test/specs/**/UK-blogPages.spec.js',
  35.         // './test/specs/**/UK-megaMenu.spec.js',
  36.  
  37.  
  38.         // './test/specs/**/US-products.spec.js',
  39.         // './test/specs/**/US-solutions.spec.js',
  40.         // './test/specs/**/US-resources.spec.js',
  41.         // './test/specs/**/US-tempCategory.spec.js',
  42.         // './test/specs/**/US-blogPages.spec.js',
  43.         // './test/specs/**/US-megaMenu.spec.js',
  44.  
  45.  
  46.         './test/specs/**/AU-products.spec.js',
  47.         './test/specs/**/AU-solutions.spec.js',
  48.         './test/specs/**/AU-resources.spec.js',
  49.         './test/specs/**/AU-tempCategory.spec.js',
  50.         './test/specs/**/AU-blogPages.spec.js',
  51.         './test/specs/**/AU-megaMenu.spec.js',
  52.  
  53.         // *********************to check button links for AU,UK and US environments***********************8
  54.  
  55.         // './test/specs/**/AUcheckUrls-prod.spec.js',
  56.         // './test/specs/**/AUcheckUrls-res.spec.js',
  57.         //  './test/specs/**/AUcheckUrls-sol.spec.js',
  58.  
  59.         // './test/specs/**/UKcheckUrls-prod.spec.js',
  60.         // './test/specs/**/UKcheckUrls-res.spec.js',
  61.         //  './test/specs/**/UKcheckUrls-sol.spec.js',
  62.  
  63.         // './test/specs/**/UScheckUrls-prod.spec.js',
  64.         // './test/specs/**/UScheckUrls-res.spec.js',
  65.         //  './test/specs/**/UScheckUrls-sol.spec.js',
  66.     ],
  67.     // Patterns to exclude.
  68.     exclude: [
  69.         // 'path/to/excluded/files'
  70.     ],
  71.     //
  72.     // ============
  73.     // Capabilities
  74.     // ============
  75.     // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
  76.     // time. Depending on the number of capabilities, WebdriverIO launches several test
  77.     // sessions. Within your capabilities you can overwrite the spec and exclude options in
  78.     // order to group specific specs to a specific capability.
  79.     //
  80.     // First, you can define how many instances should be started at the same time. Let's
  81.     // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
  82.     // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
  83.     // files and you set maxInstances to 10, all spec files will get tested at the same time
  84.     // and 30 processes will get spawned. The property handles how many capabilities
  85.     // from the same test should run tests.
  86.     //
  87.     maxInstances: 10,
  88.     //
  89.     // If you have trouble getting all important capabilities together, check out the
  90.     // Sauce Labs platform configurator - a great tool to configure your capabilities:
  91.     // https://saucelabs.com/platform/platform-configurator
  92.     //
  93.     capabilities: [
  94.         {
  95.  
  96.             // maxInstances can get overwritten per capability. So if you have an in-house Selenium
  97.             // grid with only 5 firefox instances available you can make sure that not more than
  98.             // 5 instances get started at a time.
  99.             maxInstances: 10,
  100.             //
  101.             browserName: 'chrome',
  102.  
  103.             acceptInsecureCerts: true
  104.             // If outputDir is provided WebdriverIO can capture driver session logs
  105.             // it is possible to configure which logTypes to include/exclude.
  106.             // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
  107.             // excludeDriverLogs: ['bugreport', 'server'],
  108.         },
  109.  
  110.  
  111.  
  112.     ],
  113.     //
  114.     // ===================
  115.     // Test Configurations
  116.     // ===================
  117.     // Define all options that are relevant for the WebdriverIO instance here
  118.     //
  119.     // Level of logging verbosity: trace | debug | info | warn | error | silent
  120.     logLevel: 'error',
  121.     //
  122.     // Set specific log levels per logger
  123.     // loggers:
  124.     // - webdriver, webdriverio
  125.     // - @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
  126.     // - @wdio/mocha-framework, @wdio/jasmine-framework
  127.     // - @wdio/local-runner
  128.     // - @wdio/sumologic-reporter
  129.     // - @wdio/cli, @wdio/config, @wdio/utils
  130.     // Level of logging verbosity: trace | debug | info | warn | error | silent
  131.     // logLevels: {
  132.     //     webdriver: 'info',
  133.     //     '@wdio/appium-service': 'info'
  134.     // },
  135.     //
  136.     // If you only want to run your tests until a specific amount of tests have failed use
  137.     // bail (default is 0 - don't bail, run all tests).
  138.     bail: 0,
  139.     //
  140.     // Set a base URL in order to shorten url command calls. If your `url` parameter starts
  141.     // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
  142.     // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
  143.     // gets prepended directly.
  144.     baseUrl: 'https://mandoemedia.com/',
  145.     //
  146.     // Default timeout for all waitFor* commands.
  147.     waitforTimeout: 10000,
  148.     //
  149.     // Default timeout in milliseconds for request
  150.     // if browser driver or grid doesn't send response
  151.     connectionRetryTimeout: 500000,
  152.     //
  153.     // Default request retries count
  154.     connectionRetryCount: 3,
  155.     //
  156.     // Test runner services
  157.     // Services take over a specific job you don't want to take care of. They enhance
  158.     // your test setup with almost no effort. Unlike plugins, they don't add new
  159.     // commands. Instead, they hook themselves up into the test process.
  160.     services: [['chromedriver'],
  161.     ['image-comparison',
  162.         {
  163.             baselineFolder: join(process.cwd(), './tests/visualRegressionBaseline/'),
  164.             formatImageName: '{tag}-{logName}',
  165.             screenshotPath: join(process.cwd(), './tests/visualRegressionDiff/'),
  166.             autoSaveBaseline: true,
  167.             blockOutStatusBar: true,
  168.             blockOutToolBar: true,
  169.             clearRuntimeFolder: true,
  170.             disableCSSAnimation: true
  171.         }]
  172.     ],
  173.  
  174.  
  175.     // Framework you want to run your specs with.
  176.     // The following are supported: Mocha, Jasmine, and Cucumber
  177.     // see also: https://webdriver.io/docs/frameworks
  178.     //
  179.     // Make sure you have the wdio adapter package for the specific framework installed
  180.     // before running any tests.
  181.     framework: 'mocha',
  182.     //
  183.     // The number of times to retry the entire specfile when it fails as a whole
  184.     // specFileRetries: 1,
  185.     //
  186.     // Delay in seconds between the spec file retry attempts
  187.     // specFileRetriesDelay: 0,
  188.     //
  189.     // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
  190.     // specFileRetriesDeferred: false,
  191.     //
  192.     // Test reporter for stdout.
  193.     // The only one supported by default is 'dot'
  194.     // see also: https://webdriver.io/docs/dot-reporter
  195.     reporters: ['spec'
  196.         /*    ['Allure',{
  197.             outputDir:'allure-results',
  198.             disableWebdriverStepsReporting: true,
  199.             disableWebdriverScreenshotsReporting: true,
  200.         }]*/
  201.     ],
  202.  
  203.  
  204.  
  205.     //
  206.     // Options to be passed to Mocha.
  207.     // See the full list at http://mochajs.org/
  208.     mochaOpts: {
  209.         ui: 'bdd',
  210.         timeout: 6000000000
  211.     },
  212.     //
  213.     // =====
  214.     // Hooks
  215.     // =====
  216.     // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
  217.     // it and to build services around it. You can either apply a single function or an array of
  218.     // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
  219.     // resolved to continue.
  220.     /**
  221.      * Gets executed once before all workers get launched.
  222.      * @param {Object} config wdio configuration object
  223.      * @param {Array.<Object>} capabilities list of capabilities details
  224.      */
  225.     // onPrepare: function (config, capabilities) {
  226.     // },
  227.     /**
  228.      * Gets executed before a worker process is spawned and can be used to initialise specific service
  229.      * for that worker as well as modify runtime environments in an async fashion.
  230.      * @param  {String} cid      capability id (e.g 0-0)
  231.      * @param  {[type]} caps     object containing capabilities for session that will be spawn in the worker
  232.      * @param  {[type]} specs    specs to be run in the worker process
  233.      * @param  {[type]} args     object that will be merged with the main configuration once worker is initialized
  234.      * @param  {[type]} execArgv list of string arguments passed to the worker process
  235.      */
  236.     // onWorkerStart: function (cid, caps, specs, args, execArgv) {
  237.     // },
  238.     /**
  239.      * Gets executed just after a worker process has exited.
  240.      * @param  {String} cid      capability id (e.g 0-0)
  241.      * @param  {Number} exitCode 0 - success, 1 - fail
  242.      * @param  {[type]} specs    specs to be run in the worker process
  243.      * @param  {Number} retries  number of retries used
  244.      */
  245.     // onWorkerEnd: function (cid, exitCode, specs, retries) {
  246.     // },
  247.     /**
  248.      * Gets executed just before initialising the webdriver session and test framework. It allows you
  249.      * to manipulate configurations depending on the capability or spec.
  250.      * @param {Object} config wdio configuration object
  251.      * @param {Array.<Object>} capabilities list of capabilities details
  252.      * @param {Array.<String>} specs List of spec file paths that are to be run
  253.      * @param {String} cid worker id (e.g. 0-0)
  254.      */
  255.     // beforeSession: function (config, capabilities, specs, cid) {
  256.     // },
  257.     /**
  258.      * Gets executed before test execution begins. At this point you can access to all global
  259.      * variables like `browser`. It is the perfect place to define custom commands.
  260.      * @param {Array.<Object>} capabilities list of capabilities details
  261.      * @param {Array.<String>} specs        List of spec file paths that are to be run
  262.      * @param {Object}         browser      instance of created browser/device session
  263.      */
  264.     // before: function (capabilities, specs) {
  265.     // },
  266.     /**
  267.      * Runs before a WebdriverIO command gets executed.
  268.      * @param {String} commandName hook command name
  269.      * @param {Array} args arguments that command would receive
  270.      */
  271.     // beforeCommand: function (commandName, args) {
  272.     // },
  273.     /**
  274.      * Hook that gets executed before the suite starts
  275.      * @param {Object} suite suite details
  276.      */
  277.     // beforeSuite: function (suite) {
  278.     // },
  279.     /**
  280.      * Function to be executed before a test (in Mocha/Jasmine) starts.
  281.      */
  282.     beforeTest: function (test, context) {
  283.         browser.maximizeWindow();
  284.     },
  285.     /**
  286.      * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
  287.      * beforeEach in Mocha)
  288.      */
  289.     // beforeHook: function (test, context) {
  290.     // },
  291.     /**
  292.      * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
  293.      * afterEach in Mocha)
  294.      */
  295.     // afterHook: function (test, context, { error, result, duration, passed, retries }) {
  296.     // },
  297.     /**
  298.      * Function to be executed after a test (in Mocha/Jasmine only)
  299.      * @param {Object}  test             test object
  300.      * @param {Object}  context          scope object the test was executed with
  301.      * @param {Error}   result.error     error object in case the test fails, otherwise `undefined`
  302.      * @param {Any}     result.result    return object of test function
  303.      * @param {Number}  result.duration  duration of test
  304.      * @param {Boolean} result.passed    true if test has passed, otherwise false
  305.      * @param {Object}  result.retries   informations to spec related retries, e.g. `{ attempts: 0, limit: 0 }`
  306.      */
  307.     afterTest: function (test, context, { error, result, duration, passed, retries }) {
  308.         if (error) {
  309.             browser.takeScreenshot();
  310.         }
  311.     },
  312.  
  313.  
  314.     /**
  315.      * Hook that gets executed after the suite has ended
  316.      * @param {Object} suite suite details
  317.      */
  318.     // afterSuite: function (suite) {
  319.     // },
  320.     /**
  321.      * Runs after a WebdriverIO command gets executed
  322.      * @param {String} commandName hook command name
  323.      * @param {Array} args arguments that command would receive
  324.      * @param {Number} result 0 - command success, 1 - command error
  325.      * @param {Object} error error object if any
  326.      */
  327.     // afterCommand: function (commandName, args, result, error) {
  328.     // },
  329.     /**
  330.      * Gets executed after all tests are done. You still have access to all global variables from
  331.      * the test.
  332.      * @param {Number} result 0 - test pass, 1 - test fail
  333.      * @param {Array.<Object>} capabilities list of capabilities details
  334.      * @param {Array.<String>} specs List of spec file paths that ran
  335.      */
  336.     // after: function (result, capabilities, specs) {
  337.     // },
  338.     /**
  339.      * Gets executed right after terminating the webdriver session.
  340.      * @param {Object} config wdio configuration object
  341.      * @param {Array.<Object>} capabilities list of capabilities details
  342.      * @param {Array.<String>} specs List of spec file paths that ran
  343.      */
  344.     // afterSession: function (config, capabilities, specs) {
  345.     // },
  346.     /**
  347.      * Gets executed after all workers got shut down and the process is about to exit. An error
  348.      * thrown in the onComplete hook will result in the test run failing.
  349.      * @param {Object} exitCode 0 - success, 1 - fail
  350.      * @param {Object} config wdio configuration object
  351.      * @param {Array.<Object>} capabilities list of capabilities details
  352.      * @param {<Object>} results object containing test results
  353.      */
  354.     // onComplete: function(exitCode, config, capabilities, results) {
  355.     // },
  356.     /**
  357.     * Gets executed when a refresh happens.
  358.     * @param {String} oldSessionId session ID of the old session
  359.     * @param {String} newSessionId session ID of the new session
  360.     */
  361.     // onReload: function(oldSessionId, newSessionId) {
  362.     // }
  363. }
  364.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement