All Projects β†’ zinserjan β†’ Wdio Visual Regression Service

zinserjan / Wdio Visual Regression Service

Licence: mit
Visual regression service for WebdriverIO.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Wdio Visual Regression Service

Imgursniper
πŸ“· A quick and easy Image, Screenshot and Screen recording sharing tool
Stars: ✭ 69 (-31.68%)
Mutual labels:  screenshot
Go Stare
A fast & light web screenshot without headless browser but Chrome DevTools Protocol!
Stars: ✭ 87 (-13.86%)
Mutual labels:  screenshot
Puppeteer Dart
A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
Stars: ✭ 92 (-8.91%)
Mutual labels:  screenshot
Zisui
Yet another CLI to screenshot your Storybook
Stars: ✭ 72 (-28.71%)
Mutual labels:  screenshot
Sharexin
ShareX for Linux and BSD
Stars: ✭ 79 (-21.78%)
Mutual labels:  screenshot
Budgie Screenshot Applet
Take a screenshot of your desktop, a window or region; save to disk and upload. Made with ❀️️ for Budgie Desktop.
Stars: ✭ 89 (-11.88%)
Mutual labels:  screenshot
Blazerat
πŸ”₯ Control your Linux home computer with telegram bot.
Stars: ✭ 60 (-40.59%)
Mutual labels:  screenshot
Centerline
Calculate the polygon's centerline
Stars: ✭ 94 (-6.93%)
Mutual labels:  screenshot
Blackworm
Black Worm Offical Repo
Stars: ✭ 80 (-20.79%)
Mutual labels:  screenshot
Steascree
SteaScree: Steam Cloud Screenshot Uploader
Stars: ✭ 91 (-9.9%)
Mutual labels:  screenshot
Emacs Gif Screencast
[MOVED TO GITLAB] One-frame-per-action GIF recording for optimal quality/size ratio
Stars: ✭ 74 (-26.73%)
Mutual labels:  screenshot
Apis
This Repository contains link to many Open or Closed Source APIs which I've made
Stars: ✭ 79 (-21.78%)
Mutual labels:  screenshot
Gastly
πŸ‘» Create screenshots or previews of web pages
Stars: ✭ 89 (-11.88%)
Mutual labels:  screenshot
Textshot
Python tool for grabbing text via screenshot
Stars: ✭ 1,163 (+1051.49%)
Mutual labels:  screenshot
Screenshotdemo
πŸ”₯Android ζ‰‹ζœΊεΊ”η”¨ε†…ζˆͺ屏, ζˆͺ屏监听
Stars: ✭ 93 (-7.92%)
Mutual labels:  screenshot
Page2image
πŸ“· page2image is a npm package for taking screenshots which also provides CLI command
Stars: ✭ 66 (-34.65%)
Mutual labels:  screenshot
Hishoot2i
Hishoot2i
Stars: ✭ 87 (-13.86%)
Mutual labels:  screenshot
My dotfiles
Just a collections of my dotfiles...
Stars: ✭ 101 (+0%)
Mutual labels:  screenshot
Kgif
Tool for creating gif file from capturing active window.
Stars: ✭ 94 (-6.93%)
Mutual labels:  screenshot
Vue Lottery
🎨 抽ε₯–δ»₯及ζˆͺε±δΏε­˜ε›Ύη‰‡θ‡³ζœ¬εœ°
Stars: ✭ 90 (-10.89%)
Mutual labels:  screenshot

wdio-visual-regression-service Build Status npm package

Visual regression testing with WebdriverIO.

Installation

wdio-visual-regression-service uses wdio-screenshot for capturing screenhots.

You can install wdio-visual-regression-service via NPM as usual:

$ npm install wdio-visual-regression-service --save-dev

Instructions on how to install WebdriverIO can be found here.

An example repository using the wdio-visual-regression service can be found here.

Configuration

Setup wdio-visual-regression-service by adding visual-regression to the service section of your WebdriverIO config and define your desired comparison strategy in visualRegression.

// wdio.conf.js

var path = require('path');
var 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`);
  };
}

exports.config = {
  // ...
  services: [
    'visual-regression',
  ],
  visualRegression: {
    compare: new VisualRegressionCompare.LocalCompare({
      referenceName: getScreenshotName(path.join(process.cwd(), 'screenshots/reference')),
      screenshotName: getScreenshotName(path.join(process.cwd(), 'screenshots/screen')),
      diffName: getScreenshotName(path.join(process.cwd(), 'screenshots/diff')),
      misMatchTolerance: 0.01,
    }),
    viewportChangePause: 300,
    viewports: [{ width: 320, height: 480 }, { width: 480, height: 320 }, { width: 1024, height: 768 }],
    orientations: ['landscape', 'portrait'],
  },
  // ...
};

Options

Under the key visualRegression in your wdio.config.js you can pass a configuration object with the following structure:

  • compare Object
    screenshot compare method, see Compare Methods

  • viewportChangePause Number ( default: 100 )
    wait x milliseconds after viewport change. It can take a while for the browser to re-paint. This could lead to rendering issues and produces inconsistent results between runs.

  • viewports Object[{ width: Number, height: Number }] ( default: [current-viewport] ) (desktop only)
    all screenshots will be taken in different viewport dimensions (e.g. for responsive design tests)

  • orientations String[] {landscape, portrait} ( default: [current-orientation] ) (mobile only)
    all screenshots will be taken in different screen orientations (e.g. for responsive design tests)

Compare Methods

wdio-visual-regression-service allows the usage of different screenshot comparison methods.

VisualRegressionCompare.LocalCompare

As it's name suggests LocalCompare captures screenshots locally on your computer and compares them against previous runs.

You can pass the following options to it's constructor as object:

  • referenceName Function
    pass in a function that returns the filename for the reference screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • screenshotName Function
    pass in a function that returns the filename for the current screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • diffName Function
    pass in a function that returns the filename for the diff screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • misMatchTolerance Number ( default: 0.01 )
    number between 0 and 100 that defines the degree of mismatch to consider two images as identical, increasing this value will decrease test coverage.

  • ignoreComparison String ( default: nothing )
    pass in a string with value of nothing , colors or antialiasing to adjust the comparison method.

For an example of generating screenshot filesnames dependent on the current test name, have a look at the sample code of Configuration.

VisualRegressionCompare.SaveScreenshot

This method is a stripped variant of VisualRegressionCompare.LocalCompare to capture only screenshots. This is quite useful when you just want to create reference screenshots and overwrite the previous one without diffing.

You can pass the following options to it's constructor as object:

  • screenshotName Function
    pass in a function that returns the filename for the current screenshot. Function receives a context object as first parameter with all relevant information about the command.

VisualRegressionCompare.Spectre

This method is used for uploading screenshots to the web application Spectre. Spectre is a UI for visual regression testing. It stores the screenshots and compares them which is quite useful for Continuous Integration.

You can pass the following options to it's constructor as object:

  • url String
    pass in a spectre webservice url.

  • project String
    pass in a name for your project.

  • suite String
    pass in a name for your testsuite. One project can contain several suites.

  • test Function
    pass in a function that returns the test name for the screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • browser Function
    pass in a function that returns the browser for the screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • size Function
    pass in a function that returns the size for the screenshot. Function receives a context object as first parameter with all relevant information about the command.

  • fuzzLevel Number ( default: 30 )
    number between 0 and 100 that defines the fuzz factor of Spectre's image comparison method. For more details please have a look at Spectre documentation.

Example

// wdio.conf.js

var path = require('path');
var VisualRegressionCompare = require('wdio-visual-regression-service/compare');

exports.config = {
  // ...
  services: [
    'visual-regression',
  ],
  visualRegression: {
    compare: new VisualRegressionCompare.Spectre({
      url: 'http://localhost:3000',
      project: 'my project',
      suite: 'my test suite',
      test: function getTest(context) {
        return context.test.title;
      },
      browser: function getBrowser(context) {
        return context.browser.name;
      },
      size: function getSize(context) {
        return context.meta.viewport != null ? context.meta.viewport.width : context.meta.orientation;
      },
      fuzzLevel: 30
    }),
    viewportChangePause: 300,
    viewports: [{ width: 320, height: 480 }, { width: 480, height: 320 }, { width: 1024, height: 768 }],
    orientations: ['landscape', 'portrait'],
  },
  // ...
};

Usage

wdio-visual-regression-service enhances an WebdriverIO instance with the following commands:

  • browser.checkViewport([{options}]);
  • browser.checkDocument([{options}]);
  • browser.checkElement(elementSelector, [{options}]);

All of these provide options that will help you to capture screenshots in different dimensions or to exclude unrelevant parts (e.g. content). The following options are available:

  • exclude String[]|Object[] (not yet implemented)
    exclude frequently changing parts of your screenshot, you can either pass all kinds of different WebdriverIO selector strategies that queries one or multiple elements or you can define x and y values which stretch a rectangle or polygon

  • hide String[]
    hides all elements queried by all kinds of different WebdriverIO selector strategies (via visibility: hidden)

  • remove String[]
    removes all elements queried by all kinds of different WebdriverIO selector strategies (via display: none)

  • viewports Object[{ width: Number, height: Number }] (desktop only)
    Overrides the global viewports value for this command. All screenshots will be taken in different viewport dimensions (e.g. for responsive design tests)

  • orientations String[] {landscape, portrait} (mobile only)
    Overrides the global orientations value for this command. All screenshots will be taken in different screen orientations (e.g. for responsive design tests)

  • misMatchTolerance Number
    Overrides the global misMatchTolerance value for this command. Pass in a number between 0 and 100 that defines the degree of mismatch to consider two images as identical.

  • fuzzLevel Number
    Overrides the global fuzzLevel value for this command. Pass in a number between 0 and 100 that defines the fuzz factor of Spectre's image comparison method.

  • ignoreComparison String
    Overrides the global ignoreComparison value for this command. Pass in a string with value of nothing , colors or antialiasing to adjust the comparison method.

  • viewportChangePause Number
    Overrides the global viewportChangePause value for this command. Wait x milliseconds after viewport change.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].