scottrippey / next-router-mock

Mock implementation of the Next.js Router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any support planned for `next` version `13.2.x` ?

kostia1st opened this issue · comments

Hey hello,

Love the package, use it with Storybook.

However it does not seem to work with the latest version of next, at the time of this writing.

Are there any plans to add the missing support?

OMG, I just found out it works IF you properly import MemoryRouterProvider

import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider/next-13';

That /next-13 part in the end was essential.
Either I missed this in the documentation, or the documentation could be improved.

Could you help me find the problem?
The 'next-router-mock/MemoryRouterProvider' path just tries to import next-13 and if it fails, next-12 and so on until it succeeds.
I'm thinking that this probably doesn't work with Storybook's webpack, since it will try to compile all imported modules, and can't find the legacy ones? Could you post the error you were seeing?
If so, the docs definitely need updating!

Hey, sure thing I could help.

Here's the text of that error

ModuleNotFoundError: Module not found: Error: Can't resolve 'next/dist/next-server/lib/router-context' in 'Q:\Dev\fe\node_modules\next-router-mock\dist\MemoryRouterProvider'