-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mocked next/link behavior seems inconsistenst with next/link from next.js when the as
prop is used
#89
Comments
as
prop is used
I think I need a little more detail to understand the problem. Could you explain what you DO get from Next does do something kinda surprising, so maybe this explains the problem. https://github.com/scottrippey/next-router-mock/blob/main/src/MemoryRouter.test.tsx#L369-L381
|
Thank you for researching this. What you described does sound correct, and aligns with the Next docs. I must have misunderstood when I read the docs initially. I haven't used I'd be happy to update this mock's behavior to match. You could help by creating a PR with tests, if you're up for it! |
Thanks for the response. I would be open to creating a PR. Do you have a guideline for PRs? What should be included, etc.? |
I don't have any strict guidelines around PRs. The project uses Prettier and has CI checks for everything important, so hopefully it's easy to start contributing. If you want to start by adding/updating unit tests to capture the correct, intended behavior, that's a great start! |
I created a CodeSandbox to test the Next behavior, and verified that it's just as you described. |
@sebaholesz I've got a PR ready for this! #94 |
Hey Scott! Sorry for disappearing for a couple of days. I will do the CR today. |
Not sure if I can fully review the hash behavior and compare it to the actual next router. This is probably next-router-mock specific. However, the rest of it seems good to me. I have tested the behavior locally with our pretty complex router setup and it all matches as far as I can see. Great job and thanks for taking the time! |
In our codebase we use the logic of dynamic paths and query parameters to create a more complex abstraction on top of the basic next.js routing logic. In essence, we have a couple of specific pages between we navigate using a next/link like in the example below:
If I navigate using the following link:
the actual implementation of next/link shows me the following properties:
but the mocked one gets overwritten because of the
as
prop and by this logic in the mock (specifically inMemoryRouter
):My question is, am I misunderstanding something? According to my understanding, if I navigate using a next/link where I paste arbitrary URL and query, the
as
prop should not overwrite it, as it should only modify theasPath
property of the router. Is this a bug, or a feature?The text was updated successfully, but these errors were encountered: