My test case looks something like this : In this test case, I've purposefully pushed the route in history object and given component as React.lazy(). Please let me know, what is incorrect here ?
test("should route to Item search", async () => {
const history = createMemoryHistory()
history.push("/item-search");
const { getByText } = render(
<MemoryRouter initialEntries={['/item-search']}>
<React.Suspense fallback={<div></div>}>
<Switch >
<Route exact path="/item-search" component={React.lazy(() => import('../ItemDetails/ItemDetails'))} />
</Switch>
</React.Suspense>
</MemoryRouter>
);
await waitFor(() => {
expect(getByText('Item Details')).toBeInTheDocument();
})
});