Skip to content
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

[Feature]: Support omitBackground in toHaveScreenshot in playwright config #34220

Open
wsuwt opened this issue Jan 6, 2025 · 2 comments
Open

Comments

@wsuwt
Copy link

wsuwt commented Jan 6, 2025

🚀 Feature Request

Support omitBackground in expect > toHaveScreenshot in playwright config.

Currently, it will throw a TypeScript error when setting omitBackground to playwright config. It would be great if there was somehow a way to set this globally without having to do it in each assertion.

Example

export default defineConfig({
    expect: {
      toHaveScreenshot: {
        omitBackground: true,
    }
  }
})

Motivation

A flag to globally omit background when screenshot is taken.

@Skn0tt
Copy link
Member

Skn0tt commented Jan 9, 2025

Hi, could you elaborate on why you're using omitBackground in your snapshot tests? We originally added it for printing screenshots, not for testing, so it's interesting to learn more about new usecases.

@wsuwt
Copy link
Author

wsuwt commented Jan 10, 2025

Hi, I'm using snapshot testing along with component testing. I observed minor rendering differences between each run which is totally expected but I was thinking if background can be omitted, I may be able to improve the accuracy of the test cases by eliminating spaces around the component screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants