styled-components / jest-styled-components

🔧 💅 Jest utilities for Styled Components
MIT License
1.58k stars 144 forks source link

Styled component classname changes when running jest test --watch #399

Closed Schwartz10 closed 1 year ago

Schwartz10 commented 2 years ago

Hi y'all - I'm experiencing an odd issue where a snapshot started to recently fail when just running the normal jest test command, but pass when running with the jest --watch flag. The reason is that the styled-component classname seems to change depending on how I run the tests, so the snapshot fails since the classnames mismatch.

The open source repo is here and you can replicate the testing issue on this commit. (d8f7d65a2886f6c792c945cd067870da6fff99f1

One example test to replicate - https://github.com/glifio/safe/blob/primary/components/Msig/Create/Confirm.test.tsx#L85

If you run only this test with:

npm run test:watch Create/Confirm - you'll see it should pass

When you run the same test via npm run test Create/Confirm - you'll see it fails