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