3 const fs
= require( 'fs' ),
4 path
= require( 'path' );
6 let logPath
, password
, username
;
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
) {
12 password
= 'testpass';
13 username
= 'WikiAdmin';
20 function relPath( foo
) {
21 return path
.resolve( __dirname
, '../..', foo
);
28 // Define any custom variables.
31 // Use if from tests with:
32 // browser.options.username
33 username
: process
.env
.MEDIAWIKI_USER
=== undefined ?
35 process
.env
.MEDIAWIKI_USER
,
36 password
: process
.env
.MEDIAWIKI_PASSWORD
=== undefined ?
38 process
.env
.MEDIAWIKI_PASSWORD
,
44 services
: [ 'sauce' ],
45 user
: process
.env
.SAUCE_USERNAME
,
46 key
: process
.env
.SAUCE_ACCESS_KEY
,
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.
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' )
62 // Patterns to exclude.
64 './extensions/CirrusSearch/tests/selenium/specs/**/*.js'
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.
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.
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
88 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/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.
95 browserName
: 'chrome',
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
100 process
.env
.DISPLAY
? [] : [ '--headless' ]
102 // Disable Chrome sandbox when running in Docker
103 fs
.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : []
108 // ===================
109 // Test Configurations
110 // ===================
111 // Define all options that are relevant for the WebdriverIO instance here
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.
118 // Level of logging verbosity: silent | verbose | command | data | result | error
121 // Enables colors for log output.
124 // Warns when a deprecated command is used
125 deprecationWarnings
: true,
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).
131 // Saves a screenshot to a given path if a command fails.
132 screenshotPath
: logPath
,
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.
139 process
.env
.MW_SERVER
=== undefined ?
140 'http://127.0.0.1:8080' :
141 process
.env
.MW_SERVER
143 process
.env
.MW_SCRIPT_PATH
=== undefined ?
145 process
.env
.MW_SCRIPT_PATH
148 // Default timeout for all waitFor* commands.
149 waitforTimeout
: 10000,
151 // Default timeout in milliseconds for request
152 // if Selenium Grid doesn't send response
153 connectionRetryTimeout
: 90000,
155 // Default request retries count
156 connectionRetryCount
: 3,
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
162 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
163 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
164 // Browserevent: https://github.com/webdriverio/browserevent
167 // screenshotRoot: 'my-shots',
168 // failedComparisonsRoot: 'diffs',
169 // misMatchTolerance: 0.05,
170 // screenWidth: [320,480,640,1024]
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.
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
185 // Make sure you have the wdio adapter package for the specific framework installed
186 // before running any tests.
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' ],
199 // Options to be passed to Mocha.
200 // See the full list at http://mochajs.org/
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.
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
218 // onPrepare: function (config, capabilities) {
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
227 // beforeSession: function (config, capabilities, specs) {
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
235 // before: function (capabilities, specs) {
238 * Runs before a WebdriverIO command gets executed.
239 * @param {String} commandName hook command name
240 * @param {Array} args arguments that command would receive
242 // beforeCommand: function (commandName, args) {
245 * Hook that gets executed before the suite starts
246 * @param {Object} suite suite details
248 // beforeSuite: function (suite) {
251 * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
252 * @param {Object} test test details
254 // beforeTest: function (test) {
257 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
258 * beforeEach in Mocha)
260 // beforeHook: function () {
263 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
264 * afterEach in Mocha)
266 // afterHook: function () {
269 * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
270 * @param {Object} test test details
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
279 // get current test title and clean it, to use it as file name
280 filename
= encodeURIComponent( test
.title
.replace( /\s+/g, '-' ) );
282 filePath
= this.screenshotPath
+ filename
+ '.png';
284 browser
.saveScreenshot( filePath
);
285 console
.log( '\n\tScreenshot location:', filePath
, '\n' );
289 * Hook that gets executed after the suite has ended
290 * @param {Object} suite suite details
292 // afterSuite: function (suite) {
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
301 // afterCommand: function (commandName, args, result, error) {
304 * Gets executed after all tests are done. You still have access to all global variables from
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
310 // after: function (result, capabilities, specs) {
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
318 // afterSession: function (config, capabilities, specs) {
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
326 // onComplete: function(exitCode, config, capabilities) {