After updating to 13.5.2 tests fail because of router not mounted
Unanswered
Miniature Bull Terrier posted this in #help-forum
Miniature Bull TerrierOP
Hi guys,
I updated our project to the new version. Which works when I run dev. But my unit tests now fail. I get an error that router is not mounted. But it is mocked and it have worked prior the update. We test with jest. We mocked the router by adding the next line of code in the setup file.
jest.mock("next/router", () => ({
useRouter() {
return {
push: jest.fn(),
route: "/",
pathname: "",
asPath: "",
locale: "nl-NL",
};
},
}));
"NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted"
Anyone a suggestion? Thnx!
I updated our project to the new version. Which works when I run dev. But my unit tests now fail. I get an error that router is not mounted. But it is mocked and it have worked prior the update. We test with jest. We mocked the router by adding the next line of code in the setup file.
jest.mock("next/router", () => ({
useRouter() {
return {
push: jest.fn(),
route: "/",
pathname: "",
asPath: "",
locale: "nl-NL",
};
},
}));
"NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted"
Anyone a suggestion? Thnx!
5 Replies
Which is next/router?
Miniature Bull TerrierOP
thats correct, the router in the components are imported from the correct place, so the page router "next/router"
Im tempted to say this might be a bug then
Recheck the recent PRs to see if something changed there else open a issue on GitHub