X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fselenium%2Fwdio.conf.js;h=932a8aaeaadef26d4b40e09a71a2988c263486a5;hp=541d24dc1d39002157fe1f3486c07b6462c76dd7;hb=1955a8aa5646c10bc3457a519c2a43b0b1dbb2ad;hpb=50cd683080e5401c25bfef1a83abf28b1a4f8876 diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index 541d24dc1d..932a8aaeaa 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -1,5 +1,6 @@ const fs = require( 'fs' ), path = require( 'path' ), + startChromedriver = !process.argv.includes( '--skip-chromedriver' ), logPath = process.env.LOG_DIR || path.join( __dirname, '/log' ); let ffmpeg; @@ -14,33 +15,34 @@ function filePath( test, screenshotPath, extension ) { return path.join( screenshotPath, `${fileName( test.parent )}-${fileName( test.title )}.${extension}` ); } -// relative path -function relPath( foo ) { - return path.resolve( __dirname, '../..', foo ); -} - +/** + * For more details documentation and available options, + * see + * and . + */ exports.config = { // ====== - // Custom WDIO config specific to MediaWiki + // Custom conf keys for MediaWiki + // + // Access via `browser.config.`. + // Defaults are for MediaWiki-Vagrant // ====== - // Use in a test as `browser.options.`. - // Defaults are for convenience with MediaWiki-Vagrant + mwUser: process.env.MEDIAWIKI_USER || 'Admin', + mwPwd: process.env.MEDIAWIKI_PASSWORD || 'vagrant', - // Wiki admin - username: process.env.MEDIAWIKI_USER || 'Admin', - password: process.env.MEDIAWIKI_PASSWORD || 'vagrant', - - // Base for browser.url() and Page#openTitle() - baseUrl: ( process.env.MW_SERVER || 'http://127.0.0.1:8080' ) + ( - process.env.MW_SCRIPT_PATH || '/w' - ), + // ================== + // Runner Configuration + // ================== + runner: 'local', + // The standalone chromedriver (also used by WMF CI) uses "/wd/hub". + // The one provided by wdio uses "/". + path: startChromedriver ? '/' : '/wd/hub', // ====== // Sauce Labs // ====== // See http://webdriver.io/guide/services/sauce.html // and https://github.com/bermi/sauce-connect-launcher#advanced-usage - services: process.env.SAUCE_ACCESS_KEY ? [ 'sauce' ] : [], user: process.env.SAUCE_USERNAME, key: process.env.SAUCE_ACCESS_KEY, sauceConnect: true, @@ -49,25 +51,21 @@ exports.config = { // Test Files // ================== specs: [ - relPath( './tests/selenium/wdio-mediawiki/specs/*.js' ), - relPath( './tests/selenium/specs/**/*.js' ) + './tests/selenium/wdio-mediawiki/specs/*.js', + './tests/selenium/specs/**/*.js' ], // ============ // Capabilities + // Define the different browser configurations to use ("capabilities") here. // ============ - - // How many instances of the same capability (browser) may be started at the same time. maxInstances: 1, - capabilities: [ { // For Chrome/Chromium https://sites.google.com/a/chromium.org/chromedriver/capabilities browserName: 'chrome', - maxInstances: 1, - chromeOptions: { + 'goog:chromeOptions': { // 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 + // Otherwise, use --headless. args: [ ...( process.env.DISPLAY ? [] : [ '--headless' ] ), // Chrome sandbox does not work in Docker @@ -78,53 +76,31 @@ exports.config = { // =================== // Test Configurations + // Define all options that are relevant for the WebdriverIO instance here // =================== - - // Enabling synchronous mode (via the wdio-sync package), means specs don't have to - // use Promise#then() or await for browser commands, such as like `brower.element()`. - // Instead, it will automatically pause JavaScript execution until th command finishes. - // - // For non-browser commands (such as MWBot and other promises), this means you - // have to use `browser.call()` to make sure WDIO waits for it before the next - // browser command. - sync: true, - - // Level of logging verbosity: silent | verbose | command | data | result | error + // Level of logging verbosity: trace | debug | info | warn | error | silent logLevel: 'error', - - // Enables colors for log output. - coloredLogs: true, - - // Warns when a deprecated command is used - deprecationWarnings: true, - - // Stop the tests once a certain number of failed tests have been recorded. - // Default is 0 - don't bail, run all tests. + // Stop after this many failures, or 0 to run all tests before reporting failures. bail: 0, - - // Setting this enables automatic screenshots for when a browser command fails - // It is also used by afterTest for capturig failed assertions. - // We disable it since we have our screenshot handler in the afterTest hook. - screenshotPath: null, - - // Default timeout for each waitFor* command. - waitforTimeout: 10 * 1000, - - // Framework you want to run your specs with. - // See also: http://webdriver.io/guide/testrunner/frameworks.html + // Base for browser.url() and wdio-mediawiki/Page#openTitle() + baseUrl: ( process.env.MW_SERVER || 'http://127.0.0.1:8080' ) + ( + process.env.MW_SCRIPT_PATH || '/w' + ), + services: [ + ...( startChromedriver ? [ 'chromedriver' ] : [] ), + ...( process.env.SAUCE_ACCESS_KEY ? [ 'sauce' ] : [] ) + ], + // See also: https://webdriver.io/docs/frameworks.html framework: 'mocha', - - // Test reporter for stdout. - // See also: http://webdriver.io/guide/testrunner/reporters.html - reporters: [ 'dot', 'junit' ], - reporterOptions: { - junit: { + // See also: https://webdriver.io/docs/dot-reporter.html + reporters: [ + 'dot', + // See also: https://webdriver.io/docs/junit-reporter.html#configuration + [ 'junit', { outputDir: logPath - } - }, - - // Options to be passed to Mocha. - // See the full list at http://mochajs.org/ + } ] + ], + // See also: http://mochajs.org/ mochaOpts: { ui: 'bdd', timeout: 60 * 1000 @@ -133,15 +109,12 @@ exports.config = { // ===== // Hooks // ===== - // See also: http://webdriver.io/guide/testrunner/configurationfile.html - /** - * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts. - * @param {Object} test test details - */ + * Executed before a Mocha test starts. + * @param {Object} test Mocha Test object + */ beforeTest: function ( test ) { if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) { - var logBuffer; const videoPath = filePath( test, logPath, 'mp4' ); const { spawn } = require( 'child_process' ); ffmpeg = spawn( 'ffmpeg', [ @@ -154,7 +127,7 @@ exports.config = { videoPath // output file ] ); - logBuffer = function ( buffer, prefix ) { + const logBuffer = function ( buffer, prefix ) { const lines = buffer.toString().trim().split( '\n' ); lines.forEach( function ( line ) { console.log( prefix + line ); @@ -180,10 +153,8 @@ exports.config = { } ); } }, - /** - * Save a screenshot when test fails. - * + * Executed after a Mocha test ends. * @param {Object} test Mocha Test object */ afterTest: function ( test ) {