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