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