testing with react-testing-library #198
-
I tried to setup testing with react-location and react-testing-library. It seems like react-location does not match any route. Even wildcard ones are not rendered. Does anyone have a similar problem? Or maybe can point me in the right direction for fixing it? I prepared a small example to show my problem: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
React Locations routing is asynchronous, so you'll need to use tools like |
Beta Was this translation helpful? Give feedback.
-
For those running into this issue, my tests were "passing" even when they were suppose too fail. It's an easy fix just make sure you const mainText = "Home";
describe("App", () => {
it("It should show home route", async () => {
const { getByText } = render(<App />);
await waitFor(() => getByText(mainText));
});
}); |
Beta Was this translation helpful? Give feedback.
React Locations routing is asynchronous, so you'll need to use tools like
waitFor
: https://codesandbox.io/s/react-location-testing-library-forked-3o8jr?file=/index.test.js