Last active
March 24, 2021 16:24
-
-
Save csouchet/dc5af253ed3060774f4feae781fcc60d to your computer and use it in GitHub Desktop.
Basic test with Jest-Image-Snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jest-image-snapshot custom configuration | |
function getConfig () { | |
return { | |
diffDirection: 'vertical', | |
// useful on CI (no need to retrieve the diff image, copy/paste image content from logs) | |
dumpDiffToConsole: true, | |
// use SSIM to limit false positive | |
// https://github.com/americanexpress/jest-image-snapshot#recommendations-when-using-ssim-comparison | |
comparisonMethod: 'ssim', | |
}; | |
} | |
it(`no BPMN Gateway visual regression`, async () => { | |
// Redirect the current page in the browser to a new url with puppeteer | |
const response = await page.goto(‘http://localhost:10002/non-regression.html?bpmn=./gateways.bpmn’); | |
// Be sure the page is displayed correctly with puppeteer & Jest | |
expect(response.status()).toBe(200); | |
await expect(page.title()).resolves.toMatch('BPMN Visualization Non Regression' ); | |
await page.waitForSelector(‘#bpmn-container’, { timeout: 5_000 }); | |
// Take the screenshot of the page with puppeteer | |
const image = await page.screenshot({ fullPage: true }); | |
// Compare the taken screenshot with the baseline screenshot (if exists), or create it (else) | |
const config = getConfig(); | |
expect(image).toMatchImageSnapshot(config); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment