NimaSoroush / differencify

Differencify is a library for visual regression testing
MIT License
634 stars 46 forks source link

Mobile Test #120

Closed tuan91 closed 5 years ago

tuan91 commented 5 years ago

Hi, is it possible to test various mobile devices? If so, how can I do that? Thank you!

NimaSoroush commented 5 years ago

Differencify uses Puppeteer to run the web page and take a screenshot, so there is no real mobile device integration. But what you can do is to emulate a mobile device using Puppeteer Api. The differencify script would be something like:

const Differencify = require('differencify');
const differencify = new Differencify(GlobalOptions);

const devices = require('puppeteer/DeviceDescriptors');

(async () => {
  const result = await differencify
    .init()
    .launch()
    .newPage()
    .emulate(devices['iPhone 6'])
    .goto('https://github.com/NimaSoroush/differencify')
    .waitFor(1000)
    .screenshot()
    .toMatchSnapshot()
    .result((result) => {
      console.log(result); // Prints true or false
    })
    .close()
    .end();
})();

Hope this helps!

tuan91 commented 5 years ago

Thank you!