Prior99 / jest-screenshot

A jest extension to deal with screenshots and all sorts of images.
MIT License
71 stars 21 forks source link

docker tests fail #44

Closed bboydflo closed 3 years ago

bboydflo commented 3 years ago

I am trying to run my tests inside docker with base image node:12. Locally in macos all works fine but can't figure out what goes wrong inside docker.

One of the errors looks something like that:

Expected less than 50 pixels to have changed, but 225607 pixels changed.

      16 | 
      17 |         // expect that the screenshot has not changed
    > 18 |         expect(screenshot).toMatchImageSnapshot()
         |                            ^
      19 | 
      20 |         await page.close()
      21 |     })

      at Object.<anonymous> (src/test/specs/sample.e2e.test.ts:18:28)

Do you have any idea what could go wrong? do you have some example Dockerfile that I can check and get some inspiration from?

bboydflo commented 3 years ago

After some investigation I believe it has to do with how the path of the snapshot is computed. I'll need to investigate a bit more.

bboydflo commented 3 years ago

Something weird happens. If I build the image and run the e2e tests within docker everything is fine but if I first run the e2e tests outside docker and then rerun them inside tests will fail. I assume it has to do with user permissions/read access within the image. any idea how to fix that?

bboydflo commented 3 years ago

after some more testing it turns out that I have custom fonts that are less bolder inside the docker image, therefore I chose to always run the tests inside docker.

closing

Prior99 commented 3 years ago

Yes, this is also what I am doing.