Selenium: use default value for waitforTimeout
[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 // Since Chrome v57 https://bugs.chromium.org/p/chromedriver/issues/detail?id=1625
84 chromeOptions: {
85 args: [ '--enable-automation' ]
86 }
87 } ],
88 //
89 // ===================
90 // Test Configurations
91 // ===================
92 // Define all options that are relevant for the WebdriverIO instance here
93 //
94 // By default WebdriverIO commands are executed in a synchronous way using
95 // the wdio-sync package. If you still want to run your tests in an async way
96 // e.g. using promises you can set the sync option to false.
97 sync: true,
98 //
99 // Level of logging verbosity: silent | verbose | command | data | result | error
100 logLevel: 'error',
101 //
102 // Enables colors for log output.
103 coloredLogs: true,
104 //
105 // Warns when a deprecated command is used
106 deprecationWarnings: true,
107 //
108 // If you only want to run your tests until a specific amount of tests have failed use
109 // bail (default is 0 - don't bail, run all tests).
110 bail: 0,
111 //
112 // Saves a screenshot to a given path if a command fails.
113 screenshotPath: './log/',
114 //
115 // Set a base URL in order to shorten url command calls. If your `url` parameter starts
116 // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
117 // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
118 // gets prepended directly.
119 baseUrl: (
120 process.env.MW_SERVER === undefined ?
121 'http://127.0.0.1:8080' :
122 process.env.MW_SERVER
123 ) + (
124 process.env.MW_SCRIPT_PATH === undefined ?
125 '/w' :
126 process.env.MW_SCRIPT_PATH
127 ),
128 //
129 // Default timeout for all waitFor* commands.
130 waitforTimeout: 10000,
131 //
132 // Default timeout in milliseconds for request
133 // if Selenium Grid doesn't send response
134 connectionRetryTimeout: 90000,
135 //
136 // Default request retries count
137 connectionRetryCount: 3,
138 //
139 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
140 // plugin name as key and the desired plugin options as properties. Make sure you have
141 // the plugin installed before running any tests. The following plugins are currently
142 // available:
143 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
144 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
145 // Browserevent: https://github.com/webdriverio/browserevent
146 // plugins: {
147 // webdrivercss: {
148 // screenshotRoot: 'my-shots',
149 // failedComparisonsRoot: 'diffs',
150 // misMatchTolerance: 0.05,
151 // screenWidth: [320,480,640,1024]
152 // },
153 // webdriverrtc: {},
154 // browserevent: {}
155 // },
156 //
157 // Test runner services
158 // Services take over a specific job you don't want to take care of. They enhance
159 // your test setup with almost no effort. Unlike plugins, they don't add new
160 // commands. Instead, they hook themselves up into the test process.
161 // services: [],//
162 // Framework you want to run your specs with.
163 // The following are supported: Mocha, Jasmine, and Cucumber
164 // see also: http://webdriver.io/guide/testrunner/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 // Test reporter for stdout.
171 // The only one supported by default is 'dot'
172 // see also: http://webdriver.io/guide/testrunner/reporters.html
173 reporters: [ 'spec' ],
174 //
175 // Options to be passed to Mocha.
176 // See the full list at http://mochajs.org/
177 mochaOpts: {
178 ui: 'bdd',
179 timeout: 20000
180 },
181 //
182 // =====
183 // Hooks
184 // =====
185 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
186 // it and to build services around it. You can either apply a single function or an array of
187 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
188 // resolved to continue.
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 * Gets executed just before initialising the webdriver session and test framework. It allows you
198 * to manipulate configurations depending on the capability or spec.
199 * @param {Object} config wdio configuration object
200 * @param {Array.<Object>} capabilities list of capabilities details
201 * @param {Array.<String>} specs List of spec file paths that are to be run
202 */
203 // beforeSession: function (config, capabilities, specs) {
204 // },
205 /**
206 * Gets executed before test execution begins. At this point you can access to all global
207 * variables like `browser`. It is the perfect place to define custom commands.
208 * @param {Array.<Object>} capabilities list of capabilities details
209 * @param {Array.<String>} specs List of spec file paths that are to be run
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) or a step (in Cucumber) starts.
228 * @param {Object} test test details
229 */
230 // beforeTest: function (test) {
231 // },
232 /**
233 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
234 * beforeEach in Mocha)
235 */
236 // beforeHook: function () {
237 // },
238 /**
239 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
240 * afterEach in Mocha)
241 */
242 // afterHook: function () {
243 // },
244 /**
245 * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
246 * @param {Object} test test details
247 */
248 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
249 afterTest: function ( test ) {
250 var filename, filePath;
251 // if test passed, ignore, else take and save screenshot
252 if ( test.passed ) {
253 return;
254 }
255 // get current test title and clean it, to use it as file name
256 filename = encodeURIComponent( test.title.replace( /\s+/g, '-' ) );
257 // build file path
258 filePath = this.screenshotPath + filename + '.png';
259 // save screenshot
260 browser.saveScreenshot( filePath );
261 console.log( '\n\tScreenshot location:', filePath, '\n' );
262 }
263 //
264 /**
265 * Hook that gets executed after the suite has ended
266 * @param {Object} suite suite details
267 */
268 // afterSuite: function (suite) {
269 // },
270 /**
271 * Runs after a WebdriverIO command gets executed
272 * @param {String} commandName hook command name
273 * @param {Array} args arguments that command would receive
274 * @param {Number} result 0 - command success, 1 - command error
275 * @param {Object} error error object if any
276 */
277 // afterCommand: function (commandName, args, result, error) {
278 // },
279 /**
280 * Gets executed after all tests are done. You still have access to all global variables from
281 * the test.
282 * @param {Number} result 0 - test pass, 1 - test fail
283 * @param {Array.<Object>} capabilities list of capabilities details
284 * @param {Array.<String>} specs List of spec file paths that ran
285 */
286 // after: function (result, capabilities, specs) {
287 // },
288 /**
289 * Gets executed right after terminating the webdriver session.
290 * @param {Object} config wdio configuration object
291 * @param {Array.<Object>} capabilities list of capabilities details
292 * @param {Array.<String>} specs List of spec file paths that ran
293 */
294 // afterSession: function (config, capabilities, specs) {
295 // },
296 /**
297 * Gets executed after all workers got shut down and the process is about to exit.
298 * @param {Object} exitCode 0 - success, 1 - fail
299 * @param {Object} config wdio configuration object
300 * @param {Array.<Object>} capabilities list of capabilities details
301 */
302 // onComplete: function(exitCode, config, capabilities) {
303 // }
304 };