-
Notifications
You must be signed in to change notification settings - Fork 128
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
Upgrade user-event to v14 #1605
Conversation
🦋 Changeset detectedLatest commit: f155d81 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
- removed the mocked document.createRange. This isn't necessary anymore. See https://github.com/testing-library/user-event/issues/902\#issuecomment-1092886633 - awaited userEvent calls, removed unnecessary act blocks - fixed type errors around icon types - note: there are still act warnings for some tests in the specs, even some not involving any state updates (style snapshots). Probably points to unwanted rerenders. Added a fixme comment.
- exposed the renderHook method from @testing-library/react, meant to replace the onoe from @testing-library/react-hooks, which isn't compatible with React 18. For migration purposes, I'm naming it newRenderHook--I'll remove the legacy method and rename the new one after all specs have been migrated - awaited userEvent calls and removed unnecessary act blocks
The live region wrapping toasts should not be a ul, because uls son't allow the status role (likely because it overrides list semantics anyways. Switched for divs. Found through a better axe test
- await userEvent method calls - added a new render helper to render a component tree including the ToastProvider, to reduce test boilerplate when testing business logic - improved the accesibility test to cover an actual document with a toast instead of the toast UI in isolation
- awaited userEvent methods and removed unnecessary act blocks - migrated useSidePanel to newRenderHook and removed unnecessary actHook blocks - added ariaHideApp=false to default test props in SidePanelContext to silence react-modal warning about the undefined app element - set up userEvent with delay=null in SidePanelContext to address this issue: testing-library/user-event#833 - TODO: two tests using userEvent.keyboard() are still failing. Marked as todo. - TODO: there are two act() warnings left (likely from before) when running `yarn test sidepanel` (all SidePanel-related specs)
This also adds comments on accessibility tests that inconsistently trigger axe warnings. Will be investigated and addressed separately.
Awaited userEvent calls.
Checkbox, CurrencyInput, Selector. Awaited userEvent method calls
Awaited userEvent method calls
- awaited userEvent method calls - set up userEvent with delay=null in ModalContext spec (same as in SidePanelContext)
Hamburger, Pagination, PageList, UtilityLinks, useClickOutside. Awaited userEvent method calls. Does not include the migration to new renderHook for useClickOutside, will be handled separately.
Same as in the ModalProvider and SidePanelProvider
- awaited method calls - migrated {space} to { } - TODO: migrate to the new renderHook, will be addressed separately
- await method calls - fix some TS errors
- replace imports - replace removed waitForNextUpdate by a more explicit waitFor - remove tests covering error logic. Error testing was removed in the renderHook port to RTL and we're not covering this in other components, so I think it's fine to remove. See testing-library/react-testing-library#991 for more context
See testing-library/react-testing-library#991 for context. - replaced import of renderHook to newRenderHook (will be renamed in a follow-up commit) - replaced actHook by act - (edge cases were handled in earlier commits)
6edfccf
to
f52aed2
Compare
Not sure why these specs passed locally before
Codecov Report
@@ Coverage Diff @@
## main #1605 +/- ##
==========================================
+ Coverage 92.69% 92.77% +0.07%
==========================================
Files 194 194
Lines 4026 4026
Branches 1258 1258
==========================================
+ Hits 3732 3735 +3
+ Misses 275 272 -3
Partials 19 19
|
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 looks like it was tedious. Thank you for taking care of it! I like the reduction of boilerplate code (no more act
, yay!)
I think you can avoid most of the explicit types/typecasting by adding as const
to the props objects.
Purpose
Upgrade to
@testing-library/user-event
v14.Approach and changes
@testing-library/user-event
v14user-event
methods now return promises and need to beawait
edkeyboard()
method params were renamed, e.g{esc}
👉{Escape}
;{space}
👉{ }
user-event
using{ delay: null }
. Issue ref@testing-library/react-hooks
torenderHook
from@testing-library/react
. Issue refaxe
error surfaced by an improved accessibility test (likely wasn't an issue, but a bad practice)act()
warnings...)Definition of done