mugshot-webdriverio

Adapter for WebDriverIO.

Usage no npm install needed!

<script type="module">
  import mugshotWebdriverio from 'https://cdn.skypack.dev/mugshot-webdriverio';
</script>

README

Mugshot-WebdriverIO

WebdriverIO adapter for the Mugshot Visual regression testing lib.

Usage

'use strict';
const chai = require('chai');
const expect = require('chai').expect;
const Mugshot = require('mugshot');
const chaiMugshot = require('chai-mugshot');
const webdriverio = require('webdriverio');
const WebdriverIOAdapter = require('mugshot-webdriverio');

const BROWSER = {
  desiredCapabilities: {
    browserName: 'chrome'
  }
};

describe('Visual test suite', function() {
  let mugshotOptions = {
        acceptFirstBaseline: true
      },
      webdriverioInstance, browser;

  before(function(done) {
    webdriverioInstance = webdriverio.remote(BROWSER).init()
        .then(function() {
          browser = new WebdriverIOAdapter(webdriverioInstance);
          done();
        });
  });

  it(`should look OK`, function() {
    let captureItem = {
      name: 'screenshot'
    };

    return webdriverioInstance.url('www.example.com')
        .then(function() {
          let mugshot = new Mugshot(browser, mugshotOptions);
          chai.use(chaiMugshot(mugshot));
          return expect(captureItem).to.be.identical;
        });
  });

  after(function() {
    return webdriverioInstance.end();
  });
});