-
Notifications
You must be signed in to change notification settings - Fork 841
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
[Tech debt] Remove testCustomHook
in favor of RTL renderHook
#7260
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- it's not rendering any jsx, so no need to use `.tsx`
- tests where the syntax is a straightforward conversion to `result.current`
- they're now typed properly by `renderHook`, so doing some mionr DRYing out here
…een tests - RTL auto-cleans up state between tests (https://testing-library.com/docs/react-testing-library/setup/#skipping-auto-cleanup) so tests on Enzyme that were expecting state to be preserved are now failing, and need to be updated For tests that can import directly from `@testing-library/react`, `/pure` is an option to not clear state between tests
- use a common `getRender` util for asserting on rendered content
- make it all one test instead of 3 different ones since state is resetting between tests - skip a test util since we're rerendering
cee-chen
added
testing
Issues or PRs that only affect tests - will not need changelog entries
skip-changelog
tech debt
labels
Oct 6, 2023
cee-chen
changed the title
[Tech debt] Remove DIY
[Tech debt] Remove Oct 6, 2023
testCustomHook
in favor of RTL renderHook
testCustomHook
in favor of RTL renderHook
cee-chen
force-pushed
the
tests/render-hook-cleanup
branch
from
October 6, 2023 20:22
afc58ac
to
29557c3
Compare
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
1Copenut
approved these changes
Oct 9, 2023
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.
👍 LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
skip-changelog
tech debt
testing
Issues or PRs that only affect tests - will not need changelog entries
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Twas the turn of the year of our lawd 2022, and EUI had not yet heard the good word of RTL. At the time, I wanted a way to quickly and easily unit test custom hooks and I made this horrifyingly janky DIY util to do so.
Thankfully,
@testing-library
actually has a fully fledged and battle-testedrenderHook
util that is much better in almost every measurable way (https://react-hooks-testing-library.com/reference/api), and that we've already started using in other places.This PR rips out old instances of
testCustomHook
and replaces them with therenderHook
API, and rids us of my jank 4eva.QA
If CI passes, we should be good to go 🤞
General checklist
N/A, tests/tech debt only only