ca9f8465c4422bd353ae38120ae591f7e61950c3
3 const fs
= require( 'fs' ),
4 path
= require( 'path' ),
5 logPath
= process
.env
.LOG_DIR
|| './log/';
7 function relPath( foo
) {
8 return path
.resolve( __dirname
, '../..', foo
);
13 // Custom WDIO config specific to MediaWiki
15 // Use in a test as `browser.options.<key>`.
17 // Configure wiki admin user/pass via env
18 // Defaults are for convenience with MediaWiki-Vagrant
19 username
: process
.env
.MEDIAWIKI_USER
|| 'Admin',
20 password
: process
.env
.MEDIAWIKI_PASSWORD
|| 'vagrant',
25 services
: [ 'sauce' ],
26 user
: process
.env
.SAUCE_USERNAME
,
27 key
: process
.env
.SAUCE_ACCESS_KEY
,
32 // Define which test specs should run. The pattern is relative to the directory
33 // from which `wdio` was called. Notice that, if you are calling `wdio` from an
34 // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
35 // directory is where your package.json resides, so `wdio` will be called from there.
37 relPath( './tests/selenium/specs/**/*.js' ),
38 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
39 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
40 relPath( './skins/*/tests/selenium/specs/**/*.js' )
42 // Patterns to exclude.
44 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
50 // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
51 // time. Depending on the number of capabilities, WebdriverIO launches several test
52 // sessions. Within your capabilities you can overwrite the spec and exclude options in
53 // order to group specific specs to a specific capability.
55 // First, you can define how many instances should be started at the same time. Let's
56 // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
57 // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
58 // files and you set maxInstances to 10, all spec files will get tested at the same time
59 // and 30 processes will get spawned. The property handles how many capabilities
60 // from the same test should run tests.
63 // If you have trouble getting all important capabilities together, check out the
64 // Sauce Labs platform configurator - a great tool to configure your capabilities:
65 // https://docs.saucelabs.com/reference/platforms-configurator
67 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
69 // maxInstances can get overwritten per capability. So if you have an in-house Selenium
70 // grid with only 5 firefox instances available you can make sure that not more than
71 // 5 instances get started at a time.
73 browserName
: 'chrome',
75 // If DISPLAY is set, assume running from developer machine and/or with Xvfb.
76 // Otherwise, use --headless (added in Chrome 59)
77 // https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
79 process
.env
.DISPLAY
? [] : [ '--headless' ]
81 // Chrome sandbox does not work in Docker
82 fs
.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : []
87 // ===================
88 // Test Configurations
89 // ===================
90 // Define all options that are relevant for the WebdriverIO instance here
92 // By default WebdriverIO commands are executed in a synchronous way using
93 // the wdio-sync package. If you still want to run your tests in an async way
94 // e.g. using promises you can set the sync option to false.
97 // Level of logging verbosity: silent | verbose | command | data | result | error
100 // Enables colors for log output.
103 // Warns when a deprecated command is used
104 deprecationWarnings
: true,
106 // If you only want to run your tests until a specific amount of tests have failed use
107 // bail (default is 0 - don't bail, run all tests).
110 // Saves a screenshot to a given path if a command fails.
111 screenshotPath
: logPath
,
113 // Set a base URL in order to shorten url command calls. If your `url` parameter starts
114 // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
115 // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
116 // gets prepended directly.
118 process
.env
.MW_SERVER
|| 'http://127.0.0.1:8080'
120 process
.env
.MW_SCRIPT_PATH
|| '/w'
123 // Default timeout for all waitFor* commands.
124 waitforTimeout
: 10000,
126 // Default timeout in milliseconds for request
127 // if Selenium Grid doesn't send response
128 connectionRetryTimeout
: 90000,
130 // Default request retries count
131 connectionRetryCount
: 3,
133 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
134 // plugin name as key and the desired plugin options as properties. Make sure you have
135 // the plugin installed before running any tests. The following plugins are currently
137 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
138 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
139 // Browserevent: https://github.com/webdriverio/browserevent
142 // screenshotRoot: 'my-shots',
143 // failedComparisonsRoot: 'diffs',
144 // misMatchTolerance: 0.05,
145 // screenWidth: [320,480,640,1024]
151 // Test runner services
152 // Services take over a specific job you don't want to take care of. They enhance
153 // your test setup with almost no effort. Unlike plugins, they don't add new
154 // commands. Instead, they hook themselves up into the test process.
156 // Framework you want to run your specs with.
157 // The following are supported: Mocha, Jasmine, and Cucumber
158 // see also: http://webdriver.io/guide/testrunner/frameworks.html
160 // Make sure you have the wdio adapter package for the specific framework installed
161 // before running any tests.
164 // Test reporter for stdout.
165 // The only one supported by default is 'dot'
166 // see also: http://webdriver.io/guide/testrunner/reporters.html
167 reporters
: [ 'spec', 'junit' ],
174 // Options to be passed to Mocha.
175 // See the full list at http://mochajs.org/
184 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
185 // it and to build services around it. You can either apply a single function or an array of
186 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
187 // resolved to continue.
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
194 // onPrepare: function (config, capabilities) {
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
204 // beforeSession: function (config, capabilities, specs) {
208 * Gets executed before test execution begins. At this point you can access to all global
209 * variables like `browser`. It is the perfect place to define custom commands.
210 * @param {Array.<Object>} capabilities list of capabilities details
211 * @param {Array.<String>} specs List of spec file paths that are to be run
213 // before: function (capabilities, specs) {
217 * Runs before a WebdriverIO command gets executed.
218 * @param {String} commandName hook command name
219 * @param {Array} args arguments that command would receive
221 // beforeCommand: function (commandName, args) {
225 * Hook that gets executed before the suite starts
226 * @param {Object} suite suite details
228 // beforeSuite: function (suite) {
232 * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
233 * @param {Object} test test details
235 // beforeTest: function (test) {
239 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
240 * beforeEach in Mocha)
242 // beforeHook: function () {
246 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
247 * afterEach in Mocha)
249 // afterHook: function () {
252 * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
253 * @param {Object} test test details
255 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
256 afterTest: function ( test
) {
257 var filename
, filePath
;
258 // if test passed, ignore, else take and save screenshot
262 // get current test title and clean it, to use it as file name
263 filename
= encodeURIComponent( test
.title
.replace( /\s+/g, '-' ) );
265 filePath
= this.screenshotPath
+ filename
+ '.png';
267 browser
.saveScreenshot( filePath
);
268 console
.log( '\n\tScreenshot location:', filePath
, '\n' );
272 * Hook that gets executed after the suite has ended
273 * @param {Object} suite suite details
275 // afterSuite: function (suite) {
279 * Runs after a WebdriverIO command gets executed
280 * @param {String} commandName hook command name
281 * @param {Array} args arguments that command would receive
282 * @param {Number} result 0 - command success, 1 - command error
283 * @param {Object} error error object if any
285 // afterCommand: function (commandName, args, result, error) {
289 * Gets executed after all tests are done. You still have access to all global variables from
291 * @param {Number} result 0 - test pass, 1 - test fail
292 * @param {Array.<Object>} capabilities list of capabilities details
293 * @param {Array.<String>} specs List of spec file paths that ran
295 // after: function (result, capabilities, specs) {
299 * Gets executed right after terminating the webdriver session.
300 * @param {Object} config wdio configuration object
301 * @param {Array.<Object>} capabilities list of capabilities details
302 * @param {Array.<String>} specs List of spec file paths that ran
304 // afterSession: function (config, capabilities, specs) {
308 * Gets executed after all workers got shut down and the process is about to exit.
309 * @param {Object} exitCode 0 - success, 1 - fail
310 * @param {Object} config wdio configuration object
311 * @param {Array.<Object>} capabilities list of capabilities details
313 // onComplete: function(exitCode, config, capabilities) {