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