selenium: Replace ES5 one-var assignments with const/let per line
[lhc/web/wiklou.git] / tests / selenium / wdio-mediawiki / Util.js
1 module.exports = {
2 getTestString( prefix = '' ) {
3 return prefix + Math.random().toString() + '-Iñtërnâtiônàlizætiøn';
4 },
5
6 /**
7 * Wait for a given module to reach a specific state
8 * @param {string} moduleName The name of the module to wait for
9 * @param {string} moduleStatus 'registered', 'loaded', 'loading', 'ready', 'error', 'missing'
10 * @param {int} timeout The wait time in milliseconds before the wait fails
11 */
12 waitForModuleState( moduleName, moduleStatus = 'ready', timeout = 2000 ) {
13 browser.waitUntil( () => {
14 return browser.execute( ( arg ) => {
15 return typeof mw !== 'undefined' &&
16 mw.loader.getState( arg.name ) === arg.status;
17 }, { status: moduleStatus, name: moduleName } );
18 }, timeout, 'Failed to wait for ' + moduleName + ' to be ' + moduleStatus + ' after ' + timeout + ' ms.' );
19 }
20 };