Open shawngustaw opened 1 year ago
Yes, it should definitely be doable, but I haven't tried it out yet so there might be some gotchas.
One gotcha that comes to mind: for Storybook you'll need to import a full path that includes the /next-13
route (or /next-12
etc) like this:
import { createDynamicRouteParser } from "next-router-mock/dynamic-routes/next-13";
Otherwise, I think everything else should just work. You'll call mockRouter.useParser(createDynamicRouteParser([...]))
just like the documentation says.
Please let me know if you try this out! I'd be happy to update the documentation with a Storybook example.
All of this should go in your preview.js
if you intend for it to be global. Please post back if you've tried it out? I'd be happy to add this to the documentation.
I can confirm, it works.
I know there's a
createDynamicrouterParser
but it seems like this is only intended to be used in Jest. Is there something equivalent for storybook?