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( './extensions/Wikibase/repo/tests/selenium/specs/**/*.js' ),
50 relPath( './skins/*/tests/selenium/specs/**/*.js' )
52 // Patterns to exclude
54 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
61 // How many instances of the same capability (browser) may be started at the same time.
65 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
66 browserName
: 'chrome',
69 // If DISPLAY is set, assume developer asked non-headless or CI with Xvfb.
70 // Otherwise, use --headless (added in Chrome 59)
71 // https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
73 ...( process
.env
.DISPLAY
? [] : [ '--headless' ] ),
74 // Chrome sandbox does not work in Docker
75 ...( fs
.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
80 // ===================
81 // Test Configurations
82 // ===================
84 // Enabling synchronous mode (via the wdio-sync package), means specs don't have to
85 // use Promise#then() or await for browser commands, such as like `brower.element()`.
86 // Instead, it will automatically pause JavaScript execution until th command finishes.
88 // For non-browser commands (such as MWBot and other promises), this means you
89 // have to use `browser.call()` to make sure WDIO waits for it before the next
93 // Level of logging verbosity: silent | verbose | command | data | result | error
96 // Enables colors for log output.
99 // Warns when a deprecated command is used
100 deprecationWarnings
: true,
102 // Stop the tests once a certain number of failed tests have been recorded.
103 // Default is 0 - don't bail, run all tests.
106 // Setting this enables automatic screenshots for when a browser command fails
107 // It is also used by afterTest for capturig failed assertions.
108 screenshotPath
: logPath
,
110 // Default timeout for each waitFor* command.
111 waitforTimeout
: 10 * 1000,
113 // Framework you want to run your specs with.
114 // See also: http://webdriver.io/guide/testrunner/frameworks.html
117 // Test reporter for stdout.
118 // See also: http://webdriver.io/guide/testrunner/reporters.html
119 reporters
: [ 'spec', 'junit' ],
126 // Options to be passed to Mocha.
127 // See the full list at http://mochajs.org/
136 // See also: http://webdriver.io/guide/testrunner/configurationfile.html
139 * Save a screenshot when test fails.
141 * @param {Object} test Mocha Test object
143 afterTest: function ( test
) {
145 if ( !test
.passed
) {
146 filePath
= saveScreenshot( test
.title
);
147 console
.log( '\n\tScreenshot: ' + filePath
+ '\n' );