2 /* eslint no-undef: "error" */
3 /* eslint-disable no-console, comma-dangle */
6 const path
= require( 'path' );
8 function relPath( foo
) {
9 return path
.resolve( __dirname
, '../..', foo
);
20 // Define any custom variables.
23 // Use if from tests with:
24 // browser.options.username
25 username
: process
.env
.MEDIAWIKI_USER
=== undefined ?
27 process
.env
.MEDIAWIKI_USER
,
28 password
: process
.env
.MEDIAWIKI_PASSWORD
=== undefined ?
30 process
.env
.MEDIAWIKI_PASSWORD
,
36 services
: [ 'sauce' ],
37 user
: process
.env
.SAUCE_USERNAME
,
38 key
: process
.env
.SAUCE_ACCESS_KEY
,
43 // Define which test specs should run. The pattern is relative to the directory
44 // from which `wdio` was called. Notice that, if you are calling `wdio` from an
45 // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
46 // directory is where your package.json resides, so `wdio` will be called from there.
49 relPath( './tests/selenium/specs/**/*.js' ),
50 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
51 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
52 relPath( './skins/*/tests/selenium/specs/**/*.js' ),
54 // Patterns to exclude.
56 // 'path/to/excluded/files'
62 // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
63 // time. Depending on the number of capabilities, WebdriverIO launches several test
64 // sessions. Within your capabilities you can overwrite the spec and exclude options in
65 // order to group specific specs to a specific capability.
67 // First, you can define how many instances should be started at the same time. Let's
68 // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
69 // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
70 // files and you set maxInstances to 10, all spec files will get tested at the same time
71 // and 30 processes will get spawned. The property handles how many capabilities
72 // from the same test should run tests.
76 // If you have trouble getting all important capabilities together, check out the
77 // Sauce Labs platform configurator - a great tool to configure your capabilities:
78 // https://docs.saucelabs.com/reference/platforms-configurator
80 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
82 // maxInstances can get overwritten per capability. So if you have an in-house Selenium
83 // grid with only 5 firefox instances available you can make sure that not more than
84 // 5 instances get started at a time.
87 browserName
: 'chrome',
88 // Since Chrome v57 https://bugs.chromium.org/p/chromedriver/issues/detail?id=1625
90 args
: [ '--enable-automation' ]
94 // ===================
95 // Test Configurations
96 // ===================
97 // Define all options that are relevant for the WebdriverIO instance here
99 // By default WebdriverIO commands are executed in a synchronous way using
100 // the wdio-sync package. If you still want to run your tests in an async way
101 // e.g. using promises you can set the sync option to false.
104 // Level of logging verbosity: silent | verbose | command | data | result | error
107 // Enables colors for log output.
110 // Saves a screenshot to a given path if a command fails.
111 screenshotPath
: './log/',
113 // Set a base URL in order to shorten url command calls. If your url parameter starts
114 // with "/", then the base url gets prepended.
116 process
.env
.MW_SERVER
=== undefined ?
117 'http://127.0.0.1:8080' :
118 process
.env
.MW_SERVER
120 process
.env
.MW_SCRIPT_PATH
=== undefined ?
122 process
.env
.MW_SCRIPT_PATH
125 // Default timeout for all waitFor* commands.
126 waitforTimeout
: 20000,
128 // Default timeout in milliseconds for request
129 // if Selenium Grid doesn't send response
130 connectionRetryTimeout
: 90000,
132 // Default request retries count
133 connectionRetryCount
: 3,
135 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
136 // plugin name as key and the desired plugin options as properties. Make sure you have
137 // the plugin installed before running any tests. The following plugins are currently
139 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
140 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
141 // Browserevent: https://github.com/webdriverio/browserevent
144 // screenshotRoot: 'my-shots',
145 // failedComparisonsRoot: 'diffs',
146 // misMatchTolerance: 0.05,
147 // screenWidth: [320,480,640,1024]
153 // Test runner services
154 // Services take over a specific job you don't want to take care of. They enhance
155 // your test setup with almost no effort. Unlike plugins, they don't add new
156 // commands. Instead, they hook themselves up into the test process.
158 // Framework you want to run your specs with.
159 // The following are supported: Mocha, Jasmine, and Cucumber
160 // see also: http://webdriver.io/guide/testrunner/frameworks.html
162 // Make sure you have the wdio adapter package for the specific framework installed
163 // before running any tests.
166 // Test reporter for stdout.
167 // The only one supported by default is 'dot'
168 // see also: http://webdriver.io/guide/testrunner/reporters.html
169 reporters
: [ 'spec' ],
171 // Options to be passed to Mocha.
172 // See the full list at http://mochajs.org/
181 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
182 // it and to build services around it. You can either apply a single function or an array of
183 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
184 // resolved to continue.
186 // Gets executed once before all workers get launched.
187 // onPrepare: function ( config, capabilities ) {
190 // Gets executed before test execution begins. At this point you can access all global
191 // variables, such as `browser`. It is the perfect place to define custom commands.
192 // before: function (capabilities, specs) {
195 // Hook that gets executed before the suite starts
196 // beforeSuite: function (suite) {
199 // Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
200 // beforeEach in Mocha)
201 // beforeHook: function () {
204 // Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
205 // afterEach in Mocha)
207 // Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
208 // beforeTest: function (test) {
211 // Runs before a WebdriverIO command gets executed.
212 // beforeCommand: function (commandName, args) {
215 // Runs after a WebdriverIO command gets executed
216 // afterCommand: function (commandName, args, result, error) {
219 // Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
220 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
221 afterTest: function ( test
) {
222 var filename
, filePath
;
223 // if test passed, ignore, else take and save screenshot
227 // get current test title and clean it, to use it as file name
228 filename
= encodeURIComponent( test
.title
.replace( /\s+/g, '-' ) );
230 filePath
= this.screenshotPath
+ filename
+ '.png';
232 browser
.saveScreenshot( filePath
);
233 console
.log( '\n\tScreenshot location:', filePath
, '\n' );
236 // Hook that gets executed after the suite has ended
237 // afterSuite: function (suite) {
240 // Gets executed after all tests are done. You still have access to all global variables from
242 // after: function (result, capabilities, specs) {
245 // Gets executed after all workers got shut down and the process is about to exit. It is not
246 // possible to defer the end of the process using a promise.
247 // onComplete: function(exitCode) {