-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Routing broken (documented use case fails) #869
Comments
I have dug into this issue further and it may not be specifically related to RTL. Probably a For reasons I don't entirely understand,
React router expects to see a location as follows:
The malformed This happens when it is called from inside a component, using the context-provided |
Looks like a difference between the I think if you are using the |
@alexkrolick you are sort of correct that it was a difference between the I am not entirely sure why that first call to |
Not sure if something should be added to the docs to warn against this issue. Closing this ticket for now because it's not an issue with RTL. |
@testing-library/react
version: 11.2.3Relevant code or config:
This is directly copypasta'd from:
https://testing-library.com/docs/example-react-router/
What you did:
Using React Testing Library to test react-router rendering after route change. Per docs, I provide a
Router
context with my own history object fromcreateMemoryHistory
.After changing the route by clicking a link with
userEvent
I expect the corresponding Route to be rendered.What happened:
The route change is reflected by the original page
subscribing components (eg. location retrieved by
useLocation
). However code inside the newly-matching route is not rendered. In this use case, the "You are on the about page" text never appears.Reproduction:
https://codesandbox.io/s/musing-http-rohnt?file=/src/docs.test.js
Problem description:
Cannot test full-app routing using testing library. Examples on the documentation site appear to be broken.
Suggested solution:
None at this point, but willing to work on a fix if someone can isolate the issue.
The text was updated successfully, but these errors were encountered: