Re: [csswg-drafts] [cssom] Add `toString` method on `CSSStyleSheet` (#7171)

**Use case:** Visual Regression (screenshot) testing

There is a problem with visual regression tests where they aren't cross-browser or cross-platform compatible due to subtle differences in rendering, especially fonts. So taking a screenshot of the app in a specific state, and then comparing the pixels against a previous known-good screenshot will fail just because the screenshot was done on a different OS or slightly different browser version.

If you could serialize the entire DOM and CSSOM and get hashes of each, then store those hashes next to the screenshot, you'd be able to inform a CI tool to update the snapshots when it re-runs if the hashes do not match. Allowing you to locally update the hashes when you want a new known good, without having to commit a screenshot from your machine that will only work for your machine. Then when the CI runs, it validates the screenshots, or replaces them if the hashes don't match.

This would work best if you could serialize just the part of the DOM and CSSOM that applies to a specific selector, like `[data-test="myWidget"]`. So the screenshot does not need to be of the entire page, but just the part related to that specific test.

-- 
GitHub Notification of comment by TheJaredWilcurt
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7171#issuecomment-1799112191 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 November 2023 16:25:57 UTC