NimaSoroush / differencify

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

Saving reference screenshot in particular directory issue #76

Closed grv190 closed 6 years ago

grv190 commented 6 years ago

I am not able to save the reference screenshot in particular directory. I want to save the screenshots in the 320x480 folder. How can i acheive that?

`import Differencify from 'differencify'

const puppeteer = require('puppeteer')

const differencify = new Differencify({ debug: true, imageSnapshotPath: './differencify_reports/320x480/', })

export const liveScreenshot = (key, value, width1, height1) => { return (async function takeLiveWebsiteSnapshot() { try { const target = differencify.init({ testName: value, chain: false }) await target.launch({ headless: true }) const page = await target.newPage() await page.setViewport({ width: width1, height: height1 }) await page.goto(key, { waitUntil: 'networkidle0' }) await page.content() const bodyHandle = await page.$('body') const { width, height } = await bodyHandle.boundingBox() const screenshot = await page.screenshot({ clip: { x: 0, y: 0, width, height } }) const result = await target.toMatchSnapshot(screenshot) await bodyHandle.dispose() await expect(result).toEqual(true) await console.log(result) await target.close() } catch (error) { await console.log(error) } })() } `

NimaSoroush commented 6 years ago

Based on https://github.com/NimaSoroush/differencify/blob/master/src/compareImage.js#L20

When you are running your tests using Jest, it actually overrides imageSnapshotPath value. I can put a fix for it. Will put a fix for it

NimaSoroush commented 6 years ago

@grv190 : This should be fixed now in version 1.3.2. I have added example for it as well

https://github.com/NimaSoroush/differencify/blob/master/API.md#custom-test-path https://github.com/NimaSoroush/differencify/blob/db67399167849fecafe26dbfb9541a001fecf1b7/src/integration.tests/integration.test.js#L188