I have developed the testcase for screenshot assertion on Windows machine and I am using ubuntu machine for CICD on my local test case is passing but in CICD same snapshot assertion is failing and vice versa with below error:
`Error: Screenshot comparison failed:
Expected an image 250px by 673px, received 250px by 671px. 5766 pixels (ratio 0.04 of all image pixels) are different.`
Has anyone encountered this issue or please suggest a workaround to overcome this issue
here is my code snip:
expect(await this.mainForm.screenshot()).toMatchSnapshot('form.png', { maxDiffPixels: 3 });
This thread is trying to answer question "How can a screenshot assertion testcase developed on a Windows machine pass on a Ubuntu machine used for CICD without using Docker?"
Hi, for this cas I use conditional check of testInfo.config.projects[i].use.headless. If it evaluates to true i expect page to match screenshot for headless mode, otherwise - for headed. It is kind of bad practice, but at the moment i could not figure out how to make it better This way you will have to have 2 separate screenshots for both modes
Hi, the screenshots are platform-specific, and the file name is composed of (amongst others) also the platform. So when developing tests on Windows, but running on Linux in CI, you have to generate the reference snapshots using Docker and commit those. The following page explains all that in more detail: https://playwright.dev/docs/test-snapshots
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].