-
Notifications
You must be signed in to change notification settings - Fork 844
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
fix: renderHook
imports
#7697
fix: renderHook
imports
#7697
Conversation
…t and adjust tests to account for it
…/react` to make use of the dynamic react versioning
…r erroring out in watch mode when running on React <18
@@ -6,9 +6,9 @@ | |||
* Side Public License, v 1. | |||
*/ | |||
|
|||
import { renderHook } from '@testing-library/react/pure'; // Pure is important here to preserve state between tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only place where we used @testing-library/react/pure
, and I couldn't add it to src/test/rtl/render_hook
since importing it overrides jest configuration globally (🤯), so I updated tests below to work with the regular (non-pure) renderHook
.
Preview staging links for this PR:
|
💚 Build Succeeded
cc @tkajtoch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome update! Thanks for fixing this. 🎉
That's a weird thing to happen only once the SB v8 update was merged to main 🙈
🚢 LGTM and no issues reported locally 👍
Summary
Merging in the #7646 work somehow triggered a chain of events that resulted in our
renderHook
usage in jest tests to fail when running on React <18. TherenderHook
has to be imported conditionally from@testing-library/react
for React 18 or@testing-library/react-hook
for React 16 and 17, which is done insrc/test/rtl/render_hook.ts
.I'm not 100% sure why the tests importing
renderHook
directly from@testing-library/react
weren't failing on React 16 and 17 for the past 6+ months, but the important thing is that this PR fixes all of these LOLQA
Ensure CI is passing and unit tests are passing on all React versions.