-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Viewport: Refactor ifViewportMatches to use RTL #44766
Conversation
Size Change: 0 B Total Size: 1.27 MB ℹ️ View Unchanged
|
|
||
expect( useViewportMatch ).toHaveBeenCalledWith( 'wide', '>=' ); | ||
|
||
expect( screen.queryByText( 'Hello' ) ).toBeInTheDocument(); |
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.
Just wanted to point out that query*
queries are recommended only when we're querying for elements that don't exist. In case they are expected to exist, we use get*
queries. See this post from the library creator as the rationale for that.
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.
Thanks, @tyxla.
I just realized that after reading https://testing-library.com/docs/react-testing-library/cheatsheet#queries.
What?
PR refactors
ifViewportMatches
HOC tests to use@testing-library/react
instead ofreact-test-renderer
.Why?
It is a part of recent efforts to use
@testing-library/react
as the project's primary testing library.How?
We're just using the
render
method from RTL and improving how assertions are made.Testing Instructions