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