项目作者: wix-incubator

项目描述 :
Automatic screenshot comparison using Puppeteer, Jest and Applitools Eyes.
高级语言: JavaScript
项目地址: git://github.com/wix-incubator/puppeteer-eyes.it.git
创建时间: 2018-04-23T19:00:50Z
项目社区:https://github.com/wix-incubator/puppeteer-eyes.it

开源协议:

下载


puppeteer-eyes.it

Build Status

Automatic screenshot comparison using Puppeteer, Jest and Applitools Eyes.

Getting started

  1. npm i --save-dev puppeteer-eyes.it

Setup

  1. Add Puppeteer’s page on global (if you are using jest-puppeteer you already have it on global)

  2. Require puppeteer-eyes.it:

    1. const eyes = require('puppeteer-eyes.it');
  3. Add your Applitools’ eyes key to APPLITOOLS_API_KEY env variable:

    CI

    Travis: go to your build’s options -> settings -> Environment Variables and add APPLITOOLS_API_KEY + your key

    locally

    add an .env file, with:

    1. APPLITOOLS_API_KEY=<your key here>
    • this step is not mandatory - you should use it if you want to use eyes when running locally.
    • you should put your .env file in git ignore!!!
  1. **Key name change** `EYES_API_KEY` is being replaced with `APPLITOOLS_API_KEY`. For now, we support both of them.
  1. Change your test to use eyes.it or eyes.test instead of it or test

Change screenshot baseline

In order to have a new screenshot baseline you can pass a version to your test:

  1. eyes.it('test description', async () => {
  2. // test goes here
  3. }, {version: '1.0.1'});

Default version is ‘1.0.0’

How does it work

puppeteer-eyes.it automatically takes a screenshot at the end of your test and sends it to Applitools eyes. When Eyes detects a diff in the screenshot, your build will fail and you will have a link to Applitools site with the visual diff of the screenshot.

Example

  1. const puppeteer = require('puppeteer');
  2. const eyes = require('puppeteer-eyes.it');
  3. let page;
  4. beforeAll(async () => {
  5. const browser = await puppeteer.launch();
  6. page = global.page = await browser.newPage();
  7. });
  8. afterAll(() => browser.close());
  9. eyes.it('test description', async () => {
  10. await page.goto('http://www.wix.com');
  11. expect(await page.title()).toEqual('Free Website Builder | Create a Free Website | Wix.com');
  12. });