diff --git a/e2e/utils/visual-regression.js b/e2e/utils/visual-regression.js index c16c30ea..3f299a42 100644 --- a/e2e/utils/visual-regression.js +++ b/e2e/utils/visual-regression.js @@ -161,7 +161,6 @@ module.exports.getDiffScreenshotName = (isDefaultBrowser) => { }; }; - module.exports.getRefPicName = () => { return function (context) { const testName = context.test.title; @@ -174,3 +173,7 @@ module.exports.getRefPicName = () => { return path.join(basePathRef, `${slugify(parent.toLowerCase())}/${slugify(testName.toLowerCase())}/${lastWordOfTestName.toLowerCase()}_reference_pic.png`); }; }; + +module.exports.printOutConsoleLog = () => { + browser.printOutConsoleLog = true; +}; diff --git a/wdio.conf.js b/wdio.conf.js index 5fa54f1f..aa87e4f3 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -29,7 +29,11 @@ if (process.env.BROWSER) { browsers.push({ width: resolution.width, height: resolution.height, - browserName: element + browserName: element, + 'moz:firefoxOptions': { + // flag to activate Firefox headless mode (see https://github.com/mozilla/geckodriver/blob/master/README.md#firefox-capabilities for more details about moz:firefoxOptions) + args: ['-headless'] + } }); } else { browsers.push({ @@ -51,16 +55,13 @@ if (process.env.BROWSER) { } }]; } - +const browserLogEntries = []; exports.config = { - seleniumInstallArgs: {version: '3.4.0'}, - seleniumArgs: {version: '3.4.0'}, + seleniumInstallArgs: { version: '3.4.0' }, + seleniumArgs: { version: '3.4.0' }, - specs: [ - './e2e/test/**/*.js' - ], - exclude: [ - ], + specs: ['./e2e/test/**/*.js'], + exclude: [], maxInstances: 10, @@ -119,7 +120,7 @@ exports.config = { screenshotName: getScreenshotName(isDefaultBrowser), diffName: getDiffScreenshotName(isDefaultBrowser), misMatchTolerance: 3.0 - }), + }) }, user: sauceLabsUsername, key: saucelabsAccesKey, @@ -144,7 +145,7 @@ exports.config = { require: './e2e/utils/mocha-setup.js' }, - before: function (capabilities, tests) { + before: (capabilities, tests) => { browser.currentTest = tests[0]; if (capabilities.width && capabilities.height) { browser.windowHandleSize({ @@ -152,5 +153,21 @@ exports.config = { height: capabilities.height }); } + }, + + afterTest: (test) => { + if (browser.options.desiredCapabilities.browserName === 'chrome') { + browserLogEntries.push({ + title: test.title, + result: test.passed, + messages: browser.log('browser').value, + url: browser.getUrl() + }); + } + if (browser.options.desiredCapabilities.browserName === 'chrome' && browser.printOutConsoleLog) { + console.log('console entries for %s', browser.currentTest); + console.log(JSON.stringify(browserLogEntries, null, 2)); + browser.printOutConsoleLog = false; + } } };