fix styles not being added when using toHaveStyle()#3308
Conversation
|
Hi @probablyup @kitten sorry to bother you but this is preventing us and I believe quite a few people from upgrading to 5.2.0 since the tests cannot be run with it. |
|
@Lazyuki you'll need to switch your base branch to legacy-v5 |
|
Done. |
quantizor
left a comment
There was a problem hiding this comment.
Looking at the code I don't think this will break anything, so long as people don't have a window object in their SSR environment that has an HTMLElement property. That's the heuristic we use for our IS_BROWSER check.
I might be stupid here, but doesn't JSDOM replicate the window in a node environment for jest tests by default? console.log('HTMLElement in window: ', 'HTMLElement' in window);
=> HTMLElement in window: trueIs this unwanted behaviour @probablyup? Only reason I'm asking is because my tests are now failing as a result of this change ( |
Fixes: #3297
I checked out every commit to find what caused this, and it seems that this commit and this commit were the culprit. It seems like having
windowas eitherfalseorundefinedmakesjest-dom'stoHaveStylefunction fail by not rendering any styles at all. I imagine this has something to do with how jest interacts with the window object.@probablyup I don't exactly know the reason behind these commits so I hope this doesn't break things elsewhere. I tested the build locally and I can confirm that this will fix
toHaveStyle