segmentio / niffy

Perceptual diffing suite built on Nightmare
https://open.segment.com/niffy
539 stars 24 forks source link

Jest support #5

Open NimaSoroush opened 7 years ago

NimaSoroush commented 7 years ago

Hi, Wondering if there is any possibility to run niffy with Jest? I was hoping to be able to do something like:

import Niffy from 'niffy';

describe('Header', () => {
  const basehost = 'https://www.google.com/';
  const testhost = 'https://www.google.co.uk/';

  let niffy;

  beforeAll(() => {
    niffy = new Niffy(basehost, testhost, { show: true });
  });

  afterAll(() => {
    niffy.end();
  });

  it('running visual regression tests', () => {
    niffy.goto('/?x=true');
    return niffy.test('/?x=true');
  });
});

Is there any plan for Jest support?

fiuzagr commented 6 years ago

Niffy is compatible with Jest.

Should be like:

import Niffy from 'niffy';
import co from 'co';

jest.setTimeout(200 * 1000);

describe('Header', () => {
  const basehost = 'https://www.google.com/';
  const testhost = 'https://www.google.co.uk/';

  let niffy;

  beforeAll(() => {
    niffy = new Niffy(basehost, testhost, { show: true });
  });

  afterAll(async () => {
    await co(function * () {
      return yield niffy.end();
    });
  });

  it('running visual regression tests', async () => {
    await co(function * () {
      return yield niffy.test('/');
    });
  });
});