-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Visual Regression / Screenshot Diffing #495
Comments
+1 on this feature request! We're now using blink-diff to compare screenshots generated by Cypress for visual regression testing, but having this integrated would be much better. |
@ezeedijk: These guys do continuous visual integration (pixel perfect), but not functional BDD/TDD: https://percy.io/ Pro: Have out of the box plugins for popular MVC frameworks, e.g. ember-percy Seems like visual regression would go along great with Cypress, esp. given the dashboard. Functional test + visual diff all in one dashboard. |
@ezeedijk , if you don't mind I've some questions. |
Image diff would be a great feature and make cypress a solid alternative to phantomCSS/Casper for css regression testing. |
@rndmerle No we're using blink-diff in our CI after we've run our Cypress tests. We've simply created three folders:
Updating the base set of screenshots in case of changes is a manual step. We use it very limited just to discover changes in parts of our application that are very difficult to assert other than visually, in our case mainly graphs. We do still have stability issues in some tests due to the a-synchronise nature of the cy.screenshots. So it would be nice to have visual assertions directly into Cypress. |
@ezeedijk can you take a screenshot from part of the screen like phantomCSS? Example, from |
Yes. We control the DOM. We can basically do anything we want prior to taking the screenshot. It would be trivial to "blackout" all the other areas, or even calculate the box model for the thing you want to screenshot and then resize the image accordingly. |
We currently use PhantomCSS for visual regression testing. We use it in combination with PhantomFlow, which provides very nice visual diff presentation and the ability to replace baseline images easily. Usage: We take targeted screenshots at various points during our functional test runs. We don't use screenshots to replace functional assertions per se, but we do take them within functional test flows to verify the visual state of sections of the page under various conditions. Or goal is to screenshot every screen element once under each of its states. Some functional tests may have several screenshots taken within them, others may have none. Overall, we like the functionality of PhantomCSS a lot, but we are looking for a replacement that doesn't require PhantomJS. We are excited to see what Cypress will do in this space. Some things we'd like to see:
|
This comment has been minimized.
This comment has been minimized.
Hi guys, I am the maintainer of BackstopJS. I wonder if there is some kind of interesting integration that could happen here? Happy to chat if there is some interest. |
@ezeedijk we have a proof of concept using blink-diff and that is very nice workflow - and with some UX love could be game changer. Stay tuned! |
This comment has been minimized.
This comment has been minimized.
@bahmutov I was very intrigued by your talk of your concept - any update on that? I'm looking to do the same thing basically. |
This comment has been minimized.
This comment has been minimized.
It would be really nice if cypress supports this feature sooner. |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Me when I receive plenty of
This is not helping guys, just disturbing for the whole discussion. I mean, if the topic was dying I might understand, trying to get attention. But with Gleb saying:
It does not seem that we're being abandoned 😉 |
hey @bahmutov, was just wondering since you seem to be actively working on this feature but the Fwiw I quickly threw something together (https://github.com/julianburr/cypress-match-screenshot) cause I needed to do some screen diffing for a project, but that’s obv just a temporary solution. Really looking forward to proper official support for matching screenshots. Btw, thanks so much for your work in general. Been working with Cypress for the past couple of months and its been amazing 🎉🙏 |
@julianburr it looks good, we will discuss this as soon as I get a little bit of time - we made the same thing, the pixel comparison is easy, the harder part is coming up with the entire workflow. Like where do you store images, how do you approve changes, etc. |
@bahmutov if you release an API for it let us know. I need to adjust what @julianburr did to work in CI and not sure if we have the time for it. |
we recently try doing visual regression with cypress + cypress-image-snapshot, But there are one main issue seems hard to resolve: the screenshot persist is not guaranteed caused by browser size not in control.
Is anyone has solution for this?
|
@maple-leaf Why the size is different? Did you try to define it explicitly via |
@anatoliyarkhipov Not the viewport problem, the viewport is being set at First we should stick to one concept, when take screenshot, we only take the real part we care, which is red area in image below. And this area's size will affected by whole window's size, devtool position and size which will produce diffs. |
Find solution, you can control chrome or electron window size from on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args.push('--window-size=200,800');
// whatever you return here becomes the new args
return args
}
if (browser.name === 'electron') {
args['width'] = 1600
args['height'] = 900
args['resizable'] = false;
// whatever you return here becomes the new args
return args
}
}) |
Is there a way (like an early release, or a branch to clone) to test this ? |
@dimitriy-k have you read the issue or just the title? |
Official WorkaroundFor now we do not plan to offer built-in visual regression feature in Cypress, but we did evaluate 2 commercial 3rd party services (both have nice free monthly plans) and played with Do-It-Yourself visual plugins. We have documented examples, conducted live webinars and posted our slides on the new documentation https://on.cypress.io/visual-testing |
@bahmutov I think documentation will need an update with this issue closed. |
Hey, has any integration actually happened? How could I use the backstopjs engine to do screenshot testing form me? |
@proCrichard Thanks. Will be addressed in this PR. cypress-io/cypress-documentation#1757 |
@avkonst I've been a user of Backstopjs for a while and would LOVE to see a collaboration here. |
@justinlevi @avkonst Just an update. I have just completed ember-backstop, a test-helper addon for ember apps. The Ember stack uses qunit -- but this same exact technique would work perfectly for cypress as a script helper... Example here -- the addon... and here for a tutorial... Someone should be able to take this script (which is based on Percy.io approach)... I probably don't have time to do this myself -- but I am happy to provide tips and feedback to anyone who wants to take this on. It should be pretty straightforward and it will likely address many of the issues experienced with earlier attempts. That's all I got. Sorry for the long silence. Been heads-down on developments closer to home for the past two years 😄 Best wishes everyone. |
+1 for backstopjs |
backstopJs is pretty rigid and hard for any sort of debugging and not very actively maintained, highly not recommended. |
meh I got it working with the maintainers suggestion above... but I feel these 2 concepts should be kept separate... let backstop do backstop and Cypress do Cypress ... I didn't start using Cypress for visual testing and I agree with their choice not to include one backstopjs is one of the best visual comparison tools ... maintained by original creator or not ... it's open source... contribute 😉 |
I use |
Just finished trying out BackstopJs. Wasn't a super fan of all the JSON based config (already switched to using TypeScript). Also driving your tests by configuring them seemed limiting at first, (instead of using puppeteer directly), but haven't found something I can't do yet. The real win with BackstopJS is it can easily be run in Docker, which makes it the best, OSS/Free solution I've found for my needs. I can get rock solid comparisons to run every time on Linux and Mac hosts, unlike every other library I've tried. I'm going to talk to my boss about publishing the API mocking code I wrote, which makes it easy to turn dynamic data into static. Thanks for the recommendation!! ...sorry for the off topic, but I've been trying for over a year to get reliable visual diffing tests, and finally found a solution.❤️ UPDATE: here's the Puppeteer API mocking library I mentioned: |
looks like now there's a free version (10 users + 5k snapshots). giving it a try now. |
We probably will not do this as a built-in feature in Cypress just yet. Instead please consider using open source plugins or commercial systems that built on top of Cypress test runner.
Here is our documentation guide: https://on.cypress.io/visual-testing
Find image diffing plugins in https://on.cypress.io/plugins#visual-testing
The text was updated successfully, but these errors were encountered: