Merge "objectcache: change "miss" to "renew" in metric name for preemptive refreshes"
[lhc/web/wiklou.git] / tests / selenium / wdio.conf.js
1 const fs = require( 'fs' ),
2 path = require( 'path' ),
3 saveScreenshot = require( 'wdio-mediawiki' ).saveScreenshot,
4 logPath = process.env.LOG_DIR || __dirname + '/log';
5
6 function relPath( foo ) {
7 return path.resolve( __dirname, '../..', foo );
8 }
9
10 exports.config = {
11 // ======
12 // Custom WDIO config specific to MediaWiki
13 // ======
14 // Use in a test as `browser.options.<key>`.
15 // Defaults are for convenience with MediaWiki-Vagrant
16
17 // Wiki admin
18 username: process.env.MEDIAWIKI_USER || 'Admin',
19 password: process.env.MEDIAWIKI_PASSWORD || 'vagrant',
20
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'
24 ),
25
26 // ======
27 // Sauce Labs
28 // ======
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,
34
35 // Default timeout in milliseconds for Selenium Grid requests
36 connectionRetryTimeout: 90 * 1000,
37
38 // Default request retries count
39 connectionRetryCount: 3,
40
41 // ==================
42 // Test Files
43 // ==================
44 specs: [
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' )
51 ],
52 // Patterns to exclude
53 exclude: [
54 relPath( './extensions/CirrusSearch/tests/selenium/specs/**/*.js' )
55 ],
56
57 // ============
58 // Capabilities
59 // ============
60
61 // How many instances of the same capability (browser) may be started at the same time.
62 maxInstances: 1,
63
64 capabilities: [ {
65 // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities
66 browserName: 'chrome',
67 maxInstances: 1,
68 chromeOptions: {
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
72 args: [
73 ...( process.env.DISPLAY ? [] : [ '--headless' ] ),
74 // Chrome sandbox does not work in Docker
75 ...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
76 ]
77 }
78 } ],
79
80 // ===================
81 // Test Configurations
82 // ===================
83
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.
87 //
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
90 // browser command.
91 sync: true,
92
93 // Level of logging verbosity: silent | verbose | command | data | result | error
94 logLevel: 'error',
95
96 // Enables colors for log output.
97 coloredLogs: true,
98
99 // Warns when a deprecated command is used
100 deprecationWarnings: true,
101
102 // Stop the tests once a certain number of failed tests have been recorded.
103 // Default is 0 - don't bail, run all tests.
104 bail: 0,
105
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,
109
110 // Default timeout for each waitFor* command.
111 waitforTimeout: 10 * 1000,
112
113 // Framework you want to run your specs with.
114 // See also: http://webdriver.io/guide/testrunner/frameworks.html
115 framework: 'mocha',
116
117 // Test reporter for stdout.
118 // See also: http://webdriver.io/guide/testrunner/reporters.html
119 reporters: [ 'spec', 'junit' ],
120 reporterOptions: {
121 junit: {
122 outputDir: logPath
123 }
124 },
125
126 // Options to be passed to Mocha.
127 // See the full list at http://mochajs.org/
128 mochaOpts: {
129 ui: 'bdd',
130 timeout: 60 * 1000
131 },
132
133 // =====
134 // Hooks
135 // =====
136 // See also: http://webdriver.io/guide/testrunner/configurationfile.html
137
138 /**
139 * Save a screenshot when test fails.
140 *
141 * @param {Object} test Mocha Test object
142 */
143 afterTest: function ( test ) {
144 var filePath;
145 if ( !test.passed ) {
146 filePath = saveScreenshot( test.title );
147 console.log( '\n\tScreenshot: ' + filePath + '\n' );
148 }
149 }
150 };