2 /* eslint no-undef: "error" */
3 /* eslint-disable no-console, comma-dangle */
6 const fs = require( 'fs' ),
7 path = require( 'path' );
9 function relPath( foo ) {
10 return path.resolve( __dirname, '../..', foo );
21 // Define any custom variables.
24 // Use if from tests with:
25 // browser.options.username
26 username: process.env.MEDIAWIKI_USER === undefined ?
28 process.env.MEDIAWIKI_USER,
29 password: process.env.MEDIAWIKI_PASSWORD === undefined ?
31 process.env.MEDIAWIKI_PASSWORD,
37 services: [ 'sauce' ],
38 user: process.env.SAUCE_USERNAME,
39 key: process.env.SAUCE_ACCESS_KEY,
44 // Define which test specs should run. The pattern is relative to the directory
45 // from which `wdio` was called. Notice that, if you are calling `wdio` from an
46 // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
47 // directory is where your package.json resides, so `wdio` will be called from there.
50 relPath( './tests/selenium/specs/**/*.js' ),
51 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
52 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
53 relPath( './skins/*/tests/selenium/specs/**/*.js' ),
55 // Patterns to exclude.
57 // 'path/to/excluded/files'
63 // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
64 // time. Depending on the number of capabilities, WebdriverIO launches several test
65 // sessions. Within your capabilities you can overwrite the spec and exclude options in
66 // order to group specific specs to a specific capability.
68 // First, you can define how many instances should be started at the same time. Let's
69 // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
70 // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
71 // files and you set maxInstances to 10, all spec files will get tested at the same time
72 // and 30 processes will get spawned. The property handles how many capabilities
73 // from the same test should run tests.
77 // If you have trouble getting all important capabilities together, check out the
78 // Sauce Labs platform configurator - a great tool to configure your capabilities:
79 // https://docs.saucelabs.com/reference/platforms-configurator
81 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
83 // maxInstances can get overwritten per capability. So if you have an in-house Selenium
84 // grid with only 5 firefox instances available you can make sure that not more than
85 // 5 instances get started at a time.
88 browserName: 'chrome',
90 // Run headless when there is no DISPLAY
91 // --headless: since Chrome 59 https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
93 process.env.DISPLAY ? [] : [ '--headless' ]
95 // Disable Chrome sandbox when running in Docker
96 fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : []
101 // ===================
102 // Test Configurations
103 // ===================
104 // Define all options that are relevant for the WebdriverIO instance here
106 // By default WebdriverIO commands are executed in a synchronous way using
107 // the wdio-sync package. If you still want to run your tests in an async way
108 // e.g. using promises you can set the sync option to false.
111 // Level of logging verbosity: silent | verbose | command | data | result | error
114 // Enables colors for log output.
117 // Saves a screenshot to a given path if a command fails.
118 screenshotPath: './log/',
120 // Set a base URL in order to shorten url command calls. If your url parameter starts
121 // with "/", then the base url gets prepended.
123 process.env.MW_SERVER === undefined ?
124 'http://127.0.0.1:8080' :
125 process.env.MW_SERVER
127 process.env.MW_SCRIPT_PATH === undefined ?
129 process.env.MW_SCRIPT_PATH
132 // Default timeout for all waitFor* commands.
133 waitforTimeout: 20000,
135 // Default timeout in milliseconds for request
136 // if Selenium Grid doesn't send response
137 connectionRetryTimeout: 90000,
139 // Default request retries count
140 connectionRetryCount: 3,
142 // Initialize the browser instance with a WebdriverIO plugin. The object should have the
143 // plugin name as key and the desired plugin options as properties. Make sure you have
144 // the plugin installed before running any tests. The following plugins are currently
146 // WebdriverCSS: https://github.com/webdriverio/webdrivercss
147 // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
148 // Browserevent: https://github.com/webdriverio/browserevent
151 // screenshotRoot: 'my-shots',
152 // failedComparisonsRoot: 'diffs',
153 // misMatchTolerance: 0.05,
154 // screenWidth: [320,480,640,1024]
160 // Test runner services
161 // Services take over a specific job you don't want to take care of. They enhance
162 // your test setup with almost no effort. Unlike plugins, they don't add new
163 // commands. Instead, they hook themselves up into the test process.
165 // Framework you want to run your specs with.
166 // The following are supported: Mocha, Jasmine, and Cucumber
167 // see also: http://webdriver.io/guide/testrunner/frameworks.html
169 // Make sure you have the wdio adapter package for the specific framework installed
170 // before running any tests.
173 // Test reporter for stdout.
174 // The only one supported by default is 'dot'
175 // see also: http://webdriver.io/guide/testrunner/reporters.html
176 reporters: [ 'spec' ],
178 // Options to be passed to Mocha.
179 // See the full list at http://mochajs.org/
188 // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
189 // it and to build services around it. You can either apply a single function or an array of
190 // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
191 // resolved to continue.
193 // Gets executed once before all workers get launched.
194 // onPrepare: function ( config, capabilities ) {
197 // Gets executed before test execution begins. At this point you can access all global
198 // variables, such as `browser`. It is the perfect place to define custom commands.
199 // before: function (capabilities, specs) {
202 // Hook that gets executed before the suite starts
203 // beforeSuite: function (suite) {
206 // Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
207 // beforeEach in Mocha)
208 // beforeHook: function () {
211 // Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
212 // afterEach in Mocha)
214 // Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
215 // beforeTest: function (test) {
218 // Runs before a WebdriverIO command gets executed.
219 // beforeCommand: function (commandName, args) {
222 // Runs after a WebdriverIO command gets executed
223 // afterCommand: function (commandName, args, result, error) {
226 // Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
227 // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
228 afterTest: function ( test ) {
229 var filename, filePath;
230 // if test passed, ignore, else take and save screenshot
234 // get current test title and clean it, to use it as file name
235 filename = encodeURIComponent( test.title.replace( /\s+/g, '-' ) );
237 filePath = this.screenshotPath + filename + '.png';
239 browser.saveScreenshot( filePath );
240 console.log( '\n\tScreenshot location:', filePath, '\n' );
243 // Hook that gets executed after the suite has ended
244 // afterSuite: function (suite) {
247 // Gets executed after all tests are done. You still have access to all global variables from
249 // after: function (result, capabilities, specs) {
252 // Gets executed after all workers got shut down and the process is about to exit. It is not
253 // possible to defer the end of the process using a promise.
254 // onComplete: function(exitCode) {