Running visual tests on Playwright
See original GitHub issueI was trying to find a proper workaround for having screenshots of native CSS :hover
state. As your document suggested, I couldn’t find a proper way of doing that. And I didn’t like any of the workarounds you provided in the document.
But I continued to investigate and noticed that, simulating CSS :hover
state is simply possible with Playwright. If I have a simple document with a style h1:hover { background: yellow }
, playwright routing like below gives me a screenshot of a h1 element with yellow background. This was not the case for puppeteer.
const { test, expect } = require('@playwright/test');
test('hover', async ({ page }) => {
await page.goto('http://localhost:8000/template.html');
await page.hover('h1');
await page.screenshot({ path: 'h1-hover.png' });
await expect(page).toHaveURL(/.*template.html/);
});
Is it somehow possible to use Playwright to run visual tests on Chromatic?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Visual comparisons - Playwright
Playwright Test includes the ability to produce and visually compare screenshots using await expect(page).toHaveScreenshot(). On first execution, Playwright ...
Read more >How to Perform Visual Regression Testing Using Playwright
A step-by-step tutorial that will help you learn and perform visual regression testing using Playwright to avoid unintentional disruptions.
Read more >Visual testing in Playwright - Reflect.run
Visual testing verifies that updates to an application have not caused any unexpected visual changes that would be perceived as a bug by...
Read more >Visual Testing with Playwright - TestingBot
Playwright provides automated browser testing. It offers a built-in feature to perform visual regression testing for your website.
Read more >Reliable Visual Validation using Playwright | by Rajat - Medium
Today we are talk about Visual Validation using Playwright — a powerful framework for efficient visual validation testing. Playwright is a cross-browser ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried pseudo states addon. it looks working very well with Storybook. But once I pushed changes to Chromatic it doesn’t add
.pseudo-hover
class to every element in the Story. You can see it here: https://www.chromatic.com/component?appId=6267ebb4dd54f5004a65f14a&csfId=components-button--outline-buttons-hover&buildNumber=202&k=62ebdac478667b6909b7632c-1200-interactive-true&h=55&b=-23 Compare Storybook and Snapshot versions. Is this a problem on Chromatic?Hi @muratcorlu the document you mentioned is the current state of the art. We run against various browsers, not all of which use playwright so we would need consider whether this makes sense. I’ll make an internal ticket because it is something we might think about in the future. If you write into our support we can keep you informed about our progress on that.
In the meantime you could look at using the test runner to achieve some of this (maybe not the screenshot part): https://github.com/storybookjs/test-runner#experimental-test-hook-api