2018-11-29 14:49:50 +00:00
|
|
|
/**
|
|
|
|
* See also: http://webdriver.io/guide/testrunner/configurationfile.html
|
|
|
|
*/
|
2020-06-06 15:16:41 +00:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2018-11-29 14:49:50 +00:00
|
|
|
const fs = require( 'fs' ),
|
|
|
|
saveScreenshot = require( 'wdio-mediawiki' ).saveScreenshot;
|
|
|
|
|
|
|
|
exports.config = {
|
2021-03-23 16:59:29 +00:00
|
|
|
// ==================
|
|
|
|
// Automation Protocols
|
|
|
|
// ==================
|
|
|
|
// See https://webdriver.io/docs/automationProtocols/
|
|
|
|
automationProtocol: 'devtools',
|
|
|
|
|
2018-11-29 14:49:50 +00:00
|
|
|
// ======
|
|
|
|
// Custom WDIO config specific to MediaWiki
|
|
|
|
// ======
|
|
|
|
// Use in a test as `browser.options.<key>`.
|
|
|
|
// Defaults are for convenience with MediaWiki-Vagrant
|
|
|
|
|
|
|
|
// Wiki admin
|
2020-05-20 18:34:09 +00:00
|
|
|
mwUser: process.env.MEDIAWIKI_USER || 'Admin',
|
|
|
|
mwPwd: process.env.MEDIAWIKI_PASSWORD || 'vagrant',
|
2018-11-29 14:49:50 +00:00
|
|
|
|
|
|
|
// Base for browser.url() and Page#openTitle()
|
|
|
|
baseUrl: ( process.env.MW_SERVER || 'http://127.0.0.1:8080' ) + (
|
|
|
|
process.env.MW_SCRIPT_PATH || '/w'
|
|
|
|
),
|
|
|
|
|
|
|
|
// ==================
|
|
|
|
// Test Files
|
|
|
|
// ==================
|
|
|
|
specs: [
|
|
|
|
__dirname + '/specs/*.js'
|
|
|
|
],
|
|
|
|
|
|
|
|
// ============
|
|
|
|
// Capabilities
|
|
|
|
// ============
|
|
|
|
capabilities: [ {
|
|
|
|
// https://sites.google.com/a/chromium.org/chromedriver/capabilities
|
|
|
|
browserName: 'chrome',
|
|
|
|
maxInstances: 1,
|
2020-05-20 18:34:09 +00:00
|
|
|
'goog:chromeOptions': {
|
2018-11-29 14:49:50 +00:00
|
|
|
// If DISPLAY is set, assume developer asked non-headless or CI with Xvfb.
|
|
|
|
// Otherwise, use --headless (added in Chrome 59)
|
|
|
|
// https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
|
|
|
|
args: [
|
|
|
|
...( process.env.DISPLAY ? [] : [ '--headless' ] ),
|
|
|
|
// Chrome sandbox does not work in Docker
|
|
|
|
...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] )
|
|
|
|
]
|
|
|
|
}
|
|
|
|
} ],
|
|
|
|
|
|
|
|
// ===================
|
|
|
|
// Test Configurations
|
|
|
|
// ===================
|
|
|
|
|
|
|
|
// Level of verbosity: silent | verbose | command | data | result | error
|
|
|
|
logLevel: 'error',
|
|
|
|
|
|
|
|
// Setting this enables automatic screenshots for when a browser command fails
|
|
|
|
// It is also used by afterTest for capturing failed assertions.
|
|
|
|
screenshotPath: process.env.LOG_DIR || __dirname + '/log',
|
|
|
|
|
|
|
|
// Default timeout for each waitFor* command.
|
|
|
|
waitforTimeout: 10 * 1000,
|
|
|
|
|
|
|
|
// See also: http://webdriver.io/guide/testrunner/reporters.html
|
|
|
|
reporters: [ 'spec' ],
|
|
|
|
|
|
|
|
// See also: http://mochajs.org
|
|
|
|
mochaOpts: {
|
|
|
|
ui: 'bdd',
|
|
|
|
timeout: 60 * 1000
|
|
|
|
},
|
|
|
|
|
|
|
|
// =====
|
|
|
|
// Hooks
|
|
|
|
// =====
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save a screenshot when test fails.
|
|
|
|
*
|
|
|
|
* @param {Object} test Mocha Test object
|
|
|
|
*/
|
|
|
|
afterTest: function ( test ) {
|
|
|
|
if ( !test.passed ) {
|
2020-06-06 15:16:41 +00:00
|
|
|
const filePath = saveScreenshot( test.title );
|
2018-11-29 14:49:50 +00:00
|
|
|
console.log( '\n\tScreenshot: ' + filePath + '\n' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|