wdio.conf.ts 13 KB

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