-
Notifications
You must be signed in to change notification settings - Fork 185
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
Version >= 9.12.0 breaks automatic InteractionOberserver setup with jest #699
Comments
Can you verify that it's 9.12 it first happens? What if you run just one test? It could be Jest resets the observer after a run, so before All isn't working as expected. I unfortunately won't have a chance to look into it until September. |
I've now verified that the error isn't there with version 9.11 it starts with 9.12. The error occurs only when I have two or more tests that both contains a call to I didn't have anything that resets between the test before I've added a the fix to circumvent this error (the setupIntersectionMocking/resetIntersectionMocking mentioned above) |
Could be a difference between vitest and jest, and how they reset code. Might have to go back to beforeEach for Jest tests then. |
I just want to chime in and say I'm experiencing the same issue as well using Jest and starting with 9.12, though my error looks slightly different:
@valleywood 's workaround solved the issue for me, but I only needed |
We're running into the same issue, updating from In terms of custom setup, the only thing that comes to mind is that we add a top-level import "intersection-observer"; at the top of our test setup file. |
We have a test environment where we've used mockAllIsIntersecting from react-intersection-observer/test-utils together with Jest
This has worked just fine until we updated to version 9.12.0 and beyond after that we've started to get type errors when running tests.
After that we got the error:
The error could be resolved by manually adding this code to our Jest tests:
So it seems like version 9.12.0 broke the automatic setup with Jest? 🤔
To Reproduce Try and recreate the issue in a Codesandbox:
Expected behavior
If react-intersection-observer should still be possible to run together with Jest without manually using
setupIntersectionMocking
andresetIntersectionMocking
types should be fixed.I suspect that this error comes from this update mentioned in the release notes for version 9.12.0
"Types cleanup in test-utils, getting rid of @types/jest (replaced with vitest)"
Screenshots
**Desktop **
The text was updated successfully, but these errors were encountered: