1 const fs
= require( 'fs' ),
2 path
= require( 'path' ),
3 logPath
= process
.env
.LOG_DIR
|| './log/';
5 function relPath( foo
) {
6 return path
.resolve( __dirname
, '../..', foo
);
11 // Custom WDIO config specific to MediaWiki
13 // Use in a test as `browser.options.<key>`.
15 // Configure wiki admin user/pass via env
16 // Defaults are for convenience with MediaWiki-Vagrant
17 username
: process
.env
.MEDIAWIKI_USER
|| 'Admin',
18 password
: process
.env
.MEDIAWIKI_PASSWORD
|| 'vagrant',
23 services
: [ 'sauce' ],
24 user
: process
.env
.SAUCE_USERNAME
,
25 key
: process
.env
.SAUCE_ACCESS_KEY
,
30 // Define which test specs should run. The pattern is relative to the directory
31 // from which `wdio` was called. Notice that, if you are calling `wdio` from an
32 // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
33 // directory is where your package.json resides, so `wdio` will be called from there.
35 relPath( './tests/selenium/specs/**/*.js' ),
36 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
37 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
38 relPath( './skins/*/tests/selenium/specs/**/*.js' )
40 // Patterns to exclude.
42 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
48 // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
49 // time. Depending on the number of capabilities, WebdriverIO launches several test
50 // sessions. Within your capabilities you can overwrite the spec and exclude options in
51 // order to group specific specs to a specific capability.
53 // First, you can define how many instances should be started at the same time. Let's
54 // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
55 // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
56 // files and you set maxInstances to 10, all spec files will get tested at the same time
57 // and 30 processes will get spawned. The property handles how many capabilities
58 // from the same test should run tests.
61 // If you have trouble getting all important capabilities together, check out the
62 // Sauce Labs platform configurator - a great tool to configure your capabilities:
63 // https://docs.saucelabs.com/reference/platforms-configurator
65 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
67 // maxInstances can get overwritten per capability. So if you have an in-house Selenium
68 // grid with only 5 firefox instances available you can make sure that not more than
69 // 5 instances get started at a time.
71 browserName
: 'chrome',
73 // If DISPLAY is set, assume running from developer machine and/or with Xvfb.
74 // Otherwise, use --headless (added in Chrome 59)
75 // https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
77 process
.env
.DISPLAY
? [] : [ '--headless' ]
79 // Chrome sandbox does not work in Docker
80 fs
.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : []
85 // ===================
86 // Test Configurations
87 // ===================
88 // Define all options that are relevant for the WebdriverIO instance here
90 // By default WebdriverIO commands are executed in a synchronous way using
91 // the wdio-sync package. If you still want to run your tests in an async way
92 // e.g. using promises you can set the sync option to false.
95 // Level of logging verbosity: silent | verbose | command | data | result | error
98 // Enables colors for log output.
101 // Warns when a deprecated command is used
102 deprecationWarnings
: true,
104 // If you only want to run your tests until a specific amount of tests have failed use
105 // bail (default is 0 - don't bail, run all tests).
108 // Saves a screenshot to a given path if a command fails.
109 screenshotPath
: logPath
,
111 // Set a base URL in order to shorten url command calls. If your `url` parameter starts
112 // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
113 // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
114 // gets prepended directly.
116 process
.env
.MW_SERVER
|| 'http://127.0.0.1:8080'
118 process
.env
.MW_SCRIPT_PATH
|| '/w'
121 // Default timeout for all waitFor* commands.
122 waitforTimeout
: 10000,
124 // Default timeout in milliseconds for request
125 // if Selenium Grid doesn't send response
126 connectionRetryTimeout
: 90000,
128 // Default request retries count
129 connectionRetryCount
: 3,
131 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
132 // plugin name as key and the desired plugin options as properties. Make sure you have
133 // the plugin installed before running any tests. The following plugins are currently
135 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
136 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
137 // Browserevent: https://github.com/webdriverio/browserevent
140 // screenshotRoot: 'my-shots',
141 // failedComparisonsRoot: 'diffs',
142 // misMatchTolerance: 0.05,
143 // screenWidth: [320,480,640,1024]
149 // Test runner services
150 // Services take over a specific job you don't want to take care of. They enhance
151 // your test setup with almost no effort. Unlike plugins, they don't add new
152 // commands. Instead, they hook themselves up into the test process.
154 // Framework you want to run your specs with.
155 // The following are supported: Mocha, Jasmine, and Cucumber
156 // see also: http://webdriver.io/guide/testrunner/frameworks.html
158 // Make sure you have the wdio adapter package for the specific framework installed
159 // before running any tests.
162 // Test reporter for stdout.
163 // The only one supported by default is 'dot'
164 // see also: http://webdriver.io/guide/testrunner/reporters.html
165 reporters
: [ 'spec', 'junit' ],
172 // Options to be passed to Mocha.
173 // See the full list at http://mochajs.org/
182 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
183 // it and to build services around it. You can either apply a single function or an array of
184 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
185 // resolved to continue.
188 * Gets executed once before all workers get launched.
189 * @param {Object} config wdio configuration object
190 * @param {Array.<Object>} capabilities list of capabilities details
192 // onPrepare: function (config, capabilities) {
196 * Gets executed just before initialising the webdriver session and test framework. It allows you
197 * to manipulate configurations depending on the capability or spec.
198 * @param {Object} config wdio configuration object
199 * @param {Array.<Object>} capabilities list of capabilities details
200 * @param {Array.<String>} specs List of spec file paths that are to be run
202 // beforeSession: function (config, capabilities, specs) {
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
211 // before: function (capabilities, specs) {
215 * Runs before a WebdriverIO command gets executed.
216 * @param {String} commandName hook command name
217 * @param {Array} args arguments that command would receive
219 // beforeCommand: function (commandName, args) {
223 * Hook that gets executed before the suite starts
224 * @param {Object} suite suite details
226 // beforeSuite: function (suite) {
230 * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
231 * @param {Object} test test details
233 // beforeTest: function (test) {
237 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
238 * beforeEach in Mocha)
240 // beforeHook: function () {
244 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
245 * afterEach in Mocha)
247 // afterHook: function () {
250 * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
251 * @param {Object} test test details
253 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
254 afterTest: function ( test
) {
255 var filename
, filePath
;
256 // if test passed, ignore, else take and save screenshot
260 // get current test title and clean it, to use it as file name
261 filename
= encodeURIComponent( test
.title
.replace( /\s+/g, '-' ) );
263 filePath
= this.screenshotPath
+ filename
+ '.png';
265 browser
.saveScreenshot( filePath
);
266 console
.log( '\n\tScreenshot location:', filePath
, '\n' );
270 * Hook that gets executed after the suite has ended
271 * @param {Object} suite suite details
273 // afterSuite: function (suite) {
277 * Runs after a WebdriverIO command gets executed
278 * @param {String} commandName hook command name
279 * @param {Array} args arguments that command would receive
280 * @param {Number} result 0 - command success, 1 - command error
281 * @param {Object} error error object if any
283 // afterCommand: function (commandName, args, result, error) {
287 * Gets executed after all tests are done. You still have access to all global variables from
289 * @param {Number} result 0 - test pass, 1 - test fail
290 * @param {Array.<Object>} capabilities list of capabilities details
291 * @param {Array.<String>} specs List of spec file paths that ran
293 // after: function (result, capabilities, specs) {
297 * Gets executed right after terminating the webdriver session.
298 * @param {Object} config wdio configuration object
299 * @param {Array.<Object>} capabilities list of capabilities details
300 * @param {Array.<String>} specs List of spec file paths that ran
302 // afterSession: function (config, capabilities, specs) {
306 * Gets executed after all workers got shut down and the process is about to exit.
307 * @param {Object} exitCode 0 - success, 1 - fail
308 * @param {Object} config wdio configuration object
309 * @param {Array.<Object>} capabilities list of capabilities details
311 // onComplete: function(exitCode, config, capabilities) {