And therefore, in the testing when we use render(<App/>) the testing does not know that it is wrapped inside a Browser Router. To fix this first issue we can replace the render with
import { BrowserRouter } from "react-router-dom";
render(<App /> ,{wrapper: BrowserRouter});
After adding only this (to my memory) AppRouter.test.js passes.
It also appears that the test in Integration.test.jsis now not necessary; as we render the topic in the topics page, and not on the homepage.
For TopicPage.test.js I still receive the following errors for both tests
expect(jest.fn()).toHaveBeenCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
After pulling from main it seems that some tests are failing. After going in deeper, it appears that BrowserRouter is used on index.js:
And therefore, in the testing when we use
render(<App/>)
the testing does not know that it is wrapped inside a Browser Router. To fix this first issue we can replace the render withAfter adding only this (to my memory)
AppRouter.test.js
passes. It also appears that the test inIntegration.test.js
is now not necessary; as we render the topic in the topics page, and not on the homepage.For
TopicPage.test.js
I still receive the following errors for both tests