Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/353993 )
Change subject: Add support for UI regression testing ...................................................................... Add support for UI regression testing This adds wiring for wdio-visual-regression-service See I99ae64b1a024135c4d5e338090697a24286889c2 for example usage. Bug: T107588 Change-Id: Ib444332ffbb4c52a367c5e975f9dcdc96db26bcd --- M .gitignore M package.json M tests/selenium/wdio.conf.js 3 files changed, 31 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/93/353993/1 diff --git a/.gitignore b/.gitignore index a82ae21..050f1b6 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ # Building & testing node_modules/ /tests/phpunit/phpunit.phar +/tests/selenium/screenshots # Composer /vendor diff --git a/package.json b/package.json index ee42b07..0b68ba2 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "wdio-junit-reporter": "0.2.0", "wdio-mocha-framework": "0.5.8", "wdio-spec-reporter": "0.0.5", + "wdio-visual-regression-service": "^0.8.0", "webdriverio": "4.6.2" } } diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index f132899..03fc8bb 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -5,6 +5,21 @@ 'use strict'; const path = require( 'path' ); +const VisualRegressionCompare = require('wdio-visual-regression-service/compare'); + +function getScreenshotName(basePath) { + return function(context) { + var type = context.type; + var testName = context.test.title; + var browserVersion = parseInt(context.browser.version, 10); + var browserName = context.browser.name; + var browserViewport = context.meta.viewport; + var browserWidth = browserViewport.width; + var browserHeight = browserViewport.height; + + return path.join(basePath, `${testName}_${type}_${browserName}_v${browserVersion}_${browserWidth}x${browserHeight}.png`); + }; +} function relPath( foo ) { return path.resolve( __dirname, '../..', foo ); @@ -123,6 +138,20 @@ // // Default request retries count connectionRetryCount: 3, + services: [ + 'visual-regression' + ], + visualRegression: { + compare: new VisualRegressionCompare.LocalCompare( { + referenceName: getScreenshotName( path.join( process.cwd(), 'tests/selenium/screenshots/reference' ) ), + screenshotName: getScreenshotName( path.join( process.cwd(), 'tests/selenium/screenshots/screen' ) ), + diffName: getScreenshotName( path.join( process.cwd(), 'tests/selenium/screenshots/diff' ) ), + misMatchTolerance: 0.01, + } ), + viewportChangePause: 300, + viewports: [ { width: 320, height: 480 }, { width: 480, height: 320 }, { width: 1024, height: 768 } ], + orientations: [ 'landscape', 'portrait' ] + }, // // Initialize the browser instance with a WebdriverIO plugin. The object should have the // plugin name as key and the desired plugin options as properties. Make sure you have -- To view, visit https://gerrit.wikimedia.org/r/353993 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib444332ffbb4c52a367c5e975f9dcdc96db26bcd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits