1 const fs
= require( 'fs' ),
2 path
= require( 'path' ),
3 saveScreenshot
= require( 'wdio-mediawiki' ).saveScreenshot
,
4 logPath
= process
.env
.LOG_DIR
|| __dirname
+ '/log';
6 function relPath( foo
) {
7 return path
.resolve( __dirname
, '../..', foo
);
12 // Custom WDIO config specific to MediaWiki
14 // Use in a test as `browser.options.<key>`.
15 // Defaults are for convenience with MediaWiki-Vagrant
18 username
: process
.env
.MEDIAWIKI_USER
|| 'Admin',
19 password
: process
.env
.MEDIAWIKI_PASSWORD
|| 'vagrant',
21 // Base for browser.url() and Page#openTitle()
22 baseUrl
: ( process
.env
.MW_SERVER
|| 'http://127.0.0.1:8080' ) + (
23 process
.env
.MW_SCRIPT_PATH
|| '/w'
29 // See http://webdriver.io/guide/services/sauce.html
30 // and https://docs.saucelabs.com/reference/platforms-configurator
31 services
: [ 'sauce' ],
32 user
: process
.env
.SAUCE_USERNAME
,
33 key
: process
.env
.SAUCE_ACCESS_KEY
,
35 // Default timeout in milliseconds for Selenium Grid requests
36 connectionRetryTimeout
: 90 * 1000,
38 // Default request retries count
39 connectionRetryCount
: 3,
45 relPath( './tests/selenium/wdio-mediawiki/specs/*.js' ),
46 relPath( './tests/selenium/specs/**/*.js' ),
47 relPath( './extensions/*/tests/selenium/specs/**/*.js' ),
48 relPath( './extensions/VisualEditor/modules/ve-mw/tests/selenium/specs/**/*.js' ),
49 relPath( './skins/*/tests/selenium/specs/**/*.js' )
51 // Patterns to exclude
53 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
60 // How many instances of the same capability (browser) may be started at the same time.
64 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
65 browserName
: 'chrome',
68 // If DISPLAY is set, assume developer asked non-headless or CI with Xvfb.
69 // Otherwise, use --headless (added in Chrome 59)
70 // https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
72 ...( process
.env
.DISPLAY
? [] : [ '--headless' ] ),
73 // Chrome sandbox does not work in Docker
74 ...( fs
.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
79 // ===================
80 // Test Configurations
81 // ===================
83 // Enabling synchronous mode (via the wdio-sync package), means specs don't have to
84 // use Promise#then() or await for browser commands, such as like `brower.element()`.
85 // Instead, it will automatically pause JavaScript execution until th command finishes.
87 // For non-browser commands (such as MWBot and other promises), this means you
88 // have to use `browser.call()` to make sure WDIO waits for it before the next
92 // Level of logging verbosity: silent | verbose | command | data | result | error
95 // Enables colors for log output.
98 // Warns when a deprecated command is used
99 deprecationWarnings
: true,
101 // Stop the tests once a certain number of failed tests have been recorded.
102 // Default is 0 - don't bail, run all tests.
105 // Setting this enables automatic screenshots for when a browser command fails
106 // It is also used by afterTest for capturig failed assertions.
107 screenshotPath
: logPath
,
109 // Default timeout for each waitFor* command.
110 waitforTimeout
: 10 * 1000,
112 // Framework you want to run your specs with.
113 // See also: http://webdriver.io/guide/testrunner/frameworks.html
116 // Test reporter for stdout.
117 // See also: http://webdriver.io/guide/testrunner/reporters.html
118 reporters
: [ 'spec', 'junit' ],
125 // Options to be passed to Mocha.
126 // See the full list at http://mochajs.org/
135 // See also: http://webdriver.io/guide/testrunner/configurationfile.html
138 * Save a screenshot when test fails.
140 * @param {Object} test Mocha Test object
142 afterTest: function ( test
) {
144 if ( !test
.passed
) {
145 filePath
= saveScreenshot( test
.title
);
146 console
.log( '\n\tScreenshot: ' + filePath
+ '\n' );