Merge "Sort user groups in Special:Listusers"
[lhc/web/wiklou.git] / tests / selenium / wdio.conf.js
1 'use strict';
2
3 const fs = require( 'fs' ),
4 path = require( 'path' ),
5 logPath = process.env.LOG_DIR || './log/';
6
7 function relPath( foo ) {
8 return path.resolve( __dirname, '../..', foo );
9 }
10
11 exports.config = {
12 // ======
13 // Custom WDIO config specific to MediaWiki
14 // ======
15 // Use in a test as `browser.options.<key>`.
16
17 // Configure wiki admin user/pass via env
18 // Defaults are for convenience with MediaWiki-Vagrant
19 username: process.env.MEDIAWIKI_USER || 'Admin',
20 password: process.env.MEDIAWIKI_PASSWORD || 'vagrant',
21
22 // ======
23 // Sauce Labs
24 // ======
25 services: [ 'sauce' ],
26 user: process.env.SAUCE_USERNAME,
27 key: process.env.SAUCE_ACCESS_KEY,
28
29 // ==================
30 // Specify Test Files
31 // ==================
32 // Define which test specs should run. The pattern is relative to the directory
33 // from which `wdio` was called. Notice that, if you are calling `wdio` from an
34 // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
35 // directory is where your package.json resides, so `wdio` will be called from there.
36 specs: [
37 relPath( './tests/selenium/specs/**/*.js' ),
38 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
39 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
40 relPath( './skins/*/tests/selenium/specs/**/*.js' )
41 ],
42 // Patterns to exclude.
43 exclude: [
44 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
45 ],
46
47 // ============
48 // Capabilities
49 // ============
50 // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
51 // time. Depending on the number of capabilities, WebdriverIO launches several test
52 // sessions. Within your capabilities you can overwrite the spec and exclude options in
53 // order to group specific specs to a specific capability.
54
55 // First, you can define how many instances should be started at the same time. Let's
56 // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
57 // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
58 // files and you set maxInstances to 10, all spec files will get tested at the same time
59 // and 30 processes will get spawned. The property handles how many capabilities
60 // from the same test should run tests.
61 maxInstances: 1,
62
63 // If you have trouble getting all important capabilities together, check out the
64 // Sauce Labs platform configurator - a great tool to configure your capabilities:
65 // https://docs.saucelabs.com/reference/platforms-configurator
66 //
67 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
68 capabilities: [ {
69 // maxInstances can get overwritten per capability. So if you have an in-house Selenium
70 // grid with only 5 firefox instances available you can make sure that not more than
71 // 5 instances get started at a time.
72 maxInstances: 1,
73 browserName: 'chrome',
74 chromeOptions: {
75 // If DISPLAY is set, assume running from developer machine and/or with Xvfb.
76 // Otherwise, use --headless (added in Chrome 59)
77 // https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
78 args: (
79 process.env.DISPLAY ? [] : [ '--headless' ]
80 ).concat(
81 // Chrome sandbox does not work in Docker
82 fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : []
83 )
84 }
85 } ],
86
87 // ===================
88 // Test Configurations
89 // ===================
90 // Define all options that are relevant for the WebdriverIO instance here
91 //
92 // By default WebdriverIO commands are executed in a synchronous way using
93 // the wdio-sync package. If you still want to run your tests in an async way
94 // e.g. using promises you can set the sync option to false.
95 sync: true,
96
97 // Level of logging verbosity: silent | verbose | command | data | result | error
98 logLevel: 'error',
99
100 // Enables colors for log output.
101 coloredLogs: true,
102
103 // Warns when a deprecated command is used
104 deprecationWarnings: true,
105
106 // If you only want to run your tests until a specific amount of tests have failed use
107 // bail (default is 0 - don't bail, run all tests).
108 bail: 0,
109
110 // Saves a screenshot to a given path if a command fails.
111 screenshotPath: logPath,
112
113 // Set a base URL in order to shorten url command calls. If your `url` parameter starts
114 // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
115 // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
116 // gets prepended directly.
117 baseUrl: (
118 process.env.MW_SERVER || 'http://127.0.0.1:8080'
119 ) + (
120 process.env.MW_SCRIPT_PATH || '/w'
121 ),
122
123 // Default timeout for all waitFor* commands.
124 waitforTimeout: 10000,
125
126 // Default timeout in milliseconds for request
127 // if Selenium Grid doesn't send response
128 connectionRetryTimeout: 90000,
129
130 // Default request retries count
131 connectionRetryCount: 3,
132
133 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
134 // plugin name as key and the desired plugin options as properties. Make sure you have
135 // the plugin installed before running any tests. The following plugins are currently
136 // available:
137 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
138 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
139 // Browserevent: https://github.com/webdriverio/browserevent
140 // plugins: {
141 // webdrivercss: {
142 // screenshotRoot: 'my-shots',
143 // failedComparisonsRoot: 'diffs',
144 // misMatchTolerance: 0.05,
145 // screenWidth: [320,480,640,1024]
146 // },
147 // webdriverrtc: {},
148 // browserevent: {}
149 // },
150 //
151 // Test runner services
152 // Services take over a specific job you don't want to take care of. They enhance
153 // your test setup with almost no effort. Unlike plugins, they don't add new
154 // commands. Instead, they hook themselves up into the test process.
155 // services: [],//
156 // Framework you want to run your specs with.
157 // The following are supported: Mocha, Jasmine, and Cucumber
158 // see also: http://webdriver.io/guide/testrunner/frameworks.html
159 //
160 // Make sure you have the wdio adapter package for the specific framework installed
161 // before running any tests.
162 framework: 'mocha',
163
164 // Test reporter for stdout.
165 // The only one supported by default is 'dot'
166 // see also: http://webdriver.io/guide/testrunner/reporters.html
167 reporters: [ 'spec', 'junit' ],
168 reporterOptions: {
169 junit: {
170 outputDir: logPath
171 }
172 },
173
174 // Options to be passed to Mocha.
175 // See the full list at http://mochajs.org/
176 mochaOpts: {
177 ui: 'bdd',
178 timeout: 60000
179 },
180
181 // =====
182 // Hooks
183 // =====
184 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
185 // it and to build services around it. You can either apply a single function or an array of
186 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
187 // resolved to continue.
188
189 /**
190 * Gets executed once before all workers get launched.
191 * @param {Object} config wdio configuration object
192 * @param {Array.<Object>} capabilities list of capabilities details
193 */
194 // onPrepare: function (config, capabilities) {
195 // },
196
197 /**
198 * Gets executed just before initialising the webdriver session and test framework. It allows you
199 * to manipulate configurations depending on the capability or spec.
200 * @param {Object} config wdio configuration object
201 * @param {Array.<Object>} capabilities list of capabilities details
202 * @param {Array.<String>} specs List of spec file paths that are to be run
203 */
204 // beforeSession: function (config, capabilities, specs) {
205 // },
206
207 /**
208 * Gets executed before test execution begins. At this point you can access to all global
209 * variables like `browser`. It is the perfect place to define custom commands.
210 * @param {Array.<Object>} capabilities list of capabilities details
211 * @param {Array.<String>} specs List of spec file paths that are to be run
212 */
213 // before: function (capabilities, specs) {
214 // },
215
216 /**
217 * Runs before a WebdriverIO command gets executed.
218 * @param {String} commandName hook command name
219 * @param {Array} args arguments that command would receive
220 */
221 // beforeCommand: function (commandName, args) {
222 // },
223
224 /**
225 * Hook that gets executed before the suite starts
226 * @param {Object} suite suite details
227 */
228 // beforeSuite: function (suite) {
229 // },
230
231 /**
232 * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
233 * @param {Object} test test details
234 */
235 // beforeTest: function (test) {
236 // },
237
238 /**
239 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
240 * beforeEach in Mocha)
241 */
242 // beforeHook: function () {
243 // },
244
245 /**
246 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
247 * afterEach in Mocha)
248 */
249 // afterHook: function () {
250 // },
251 /**
252 * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
253 * @param {Object} test test details
254 */
255 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
256 afterTest: function ( test ) {
257 var filename, filePath;
258 // if test passed, ignore, else take and save screenshot
259 if ( test.passed ) {
260 return;
261 }
262 // get current test title and clean it, to use it as file name
263 filename = encodeURIComponent( test.title.replace( /\s+/g, '-' ) );
264 // build file path
265 filePath = this.screenshotPath + filename + '.png';
266 // save screenshot
267 browser.saveScreenshot( filePath );
268 console.log( '\n\tScreenshot location:', filePath, '\n' );
269 }
270
271 /**
272 * Hook that gets executed after the suite has ended
273 * @param {Object} suite suite details
274 */
275 // afterSuite: function (suite) {
276 // },
277
278 /**
279 * Runs after a WebdriverIO command gets executed
280 * @param {String} commandName hook command name
281 * @param {Array} args arguments that command would receive
282 * @param {Number} result 0 - command success, 1 - command error
283 * @param {Object} error error object if any
284 */
285 // afterCommand: function (commandName, args, result, error) {
286 // },
287
288 /**
289 * Gets executed after all tests are done. You still have access to all global variables from
290 * the test.
291 * @param {Number} result 0 - test pass, 1 - test fail
292 * @param {Array.<Object>} capabilities list of capabilities details
293 * @param {Array.<String>} specs List of spec file paths that ran
294 */
295 // after: function (result, capabilities, specs) {
296 // },
297
298 /**
299 * Gets executed right after terminating the webdriver session.
300 * @param {Object} config wdio configuration object
301 * @param {Array.<Object>} capabilities list of capabilities details
302 * @param {Array.<String>} specs List of spec file paths that ran
303 */
304 // afterSession: function (config, capabilities, specs) {
305 // },
306
307 /**
308 * Gets executed after all workers got shut down and the process is about to exit.
309 * @param {Object} exitCode 0 - success, 1 - fail
310 * @param {Object} config wdio configuration object
311 * @param {Array.<Object>} capabilities list of capabilities details
312 */
313 // onComplete: function(exitCode, config, capabilities) {
314 // }
315 };