wdio-saucelabs.conf.js 12 KB

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