Skip to content
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

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Conversation

tkajtoch
Copy link
Member

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. The renderHook 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 in src/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 LOL

QA

Ensure CI is passing and unit tests are passing on all React versions.

…/react` to make use of the dynamic react versioning
…r erroring out in watch mode when running on React <18
@tkajtoch tkajtoch self-assigned this Apr 17, 2024
@tkajtoch tkajtoch requested a review from a team as a code owner April 17, 2024 22:39
@@ -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
Copy link
Member Author

@tkajtoch tkajtoch Apr 17, 2024

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.

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @tkajtoch

Copy link
Contributor

@mgadewoll mgadewoll left a 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 👍

@tkajtoch tkajtoch merged commit 29fd2e7 into elastic:main Apr 18, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants