wdio.conf.js 12 KB

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