Jest on dynamic routing
Doing unit tests on Nextjs page with route of id, how do I pass in the query of id to not get the
Error: Uncaught [TypeError: Cannot read property 'query' of null]
error?
2 Replies
do I need to mock the router or something else?
Update: you have to mock next/router
ie something like the following at the top of the file:
Ref: https://stackoverflow.com/a/69126334/12539335
Stack Overflow
Mocking NextJS router events with Jest
I am trying to mock NextJS router events with Jest. Found a relevant resource right here at NextJS router & Jest. The implementation there is very similar to mine.
However, the solution mentioned