-
Notifications
You must be signed in to change notification settings - Fork 4
Fix devtools test #3
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 devtools test #3
Conversation
@TkDodo Since we upgraded react query to the latest version getByRole only works with actual buttons now, not with elements with role |
hmm, I'm not sure the issues are related, as we use the "right" role. A
works 🤔 |
That is weird, although I tried investigating the issue as well, and I thought maybe it has something to do with the quotes in the query hash not getting appropriately escaped, but I replaced it with a static label, and it still didn't work. Also testing library shows all the elements with that role for suggestions, and our div wasn't listed in it. Finally, since we are using the |
so this test works fine for me on the react-18 branch, so I don't think that testing-library has a bug:
I think the real issue is waiting for - await screen.findByText(getByTextContent(`1${currentQuery?.queryHash}`))
+ await screen.findByRole('button', {
+ name: `Open query details for ${currentQuery?.queryHash}`,
+ }) so I think thats the better fix. also, isn't it a bit we don't have any - await screen.findByText(/query details/i)
+ await waitFor(() => {
+ expect(screen.queryByText(/query details/i)).toBeInTheDocument()
+ }) what do you think? |
Sorry, my bad. You are right. It does work if I use findByRole with
Do we really need to use expect? Because the findBy* and getBy* methods fail the tests with very descriptive errors if they cannot find the respective element. Also, I am not sure using |
I think you are right. I was coming from the eslint rule that requires each test to have an |
No description provided.