question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] a toMatchScreenshot() for comparing two different screenshots

See original GitHub issue

We currently have expect(screenshot).toMatchSnapshot(name[, options]) which is nice when comparing against at snapshot but it doesn’t work when comparing a screenshot against a reference website which is useful for doing visual regression to see what has changed. I propose that we add a toMatchScreenshot(screenshot[, options]) that could be used for something like this:


page.goto("production.example.com")
const ref = await page.screenshot({
  animations: "disabled",
  fullPage: true,
  scale: "css"
});

page.goto("localhost:8080")
const test = await page.screenshot({
  animations: "disabled",
  fullPage: true,
  scale: "css"
});

expect(test, "should  match reference").toMatchScreenshot(ref, {
  maxDiffPixelRatio: 0,
  maxDiffPixels: 0,
  threshold: 0
});

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Dec 14, 2022

@NikkTod no, it’s not coming to 1.29. Will be moved to 1.30 instead

1reaction
dgozmancommented, Nov 24, 2022

@ambiguous48 Yes, so far I think that toMatchImage() could support both buffers and file paths.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright Visual Comparisons | Playwright part - 28 - YouTube
The visual comparison is really a great feature.Playwright Test includes the ability to produce and visually compare screenshots using ...
Read more >
how to implement comparing two screenshots in one test ...
You can do something like this: test('compare screenshots', async ({ page }, testInfo)=>{ await page.goto(pageUrl); const screenshotTarget ...
Read more >
Snapshot Testing
A typical snapshot test case renders a UI component, takes a snapshot, then compares it to a reference snapshot file stored alongside the...
Read more >
Everything you need to know about Visual Regression Testing ...
It's easy to compare two images pixel by pixel but the trouble is that ... With PlayWright, there's a page.screenshot() API right out...
Read more >
Snapshot | Guide
The test will fail if the two snapshots do not match: either the change is ... To snapshot a value, you can use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found