Making next/router
and next/link
more testable
#38248
Replies: 4 comments 1 reply
-
For documentation here my issue #38230 regarding the problem with 12.2.0 which broke my tests to. But your package helped me so far. |
Beta Was this translation helpful? Give feedback.
-
The issue boils down to 2 path-based problems.
So I'd like to suggest a 2-part solution.
|
Beta Was this translation helpful? Give feedback.
-
How about Next.JS provide a |
Beta Was this translation helpful? Give feedback.
-
I would expect frameworks such as Next.js to start treating testing as a first-class citizen in their API layer. It is really sad that there is no official support regarding testing common use cases such as navigation. Props to @scottrippey for investing his own time into such a huge effort. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd love to discuss how we could work together to make Next apps more testable.
I’ve been working on
next-router-mock
, which helps tests to mocknext/router
andnext/link
. However, there’s some difficulty in mocking these modules, and the workarounds all rely on internal paths, which frequently change between Next releases.I'm sure we can create a solution to make this easily preventable.
Some examples:
shared/lib/router/utils
and others)shared/lib/router-context
module, which has changed paths in past releasesnext/link
broke inv12.2.0
because it now uses aContext
instead of therouter
singletonI would love to discuss ways to work together to help minimize these kinds of breaking changes. There are a lot of folks using
next-router-mock
to unit-test their Next application, and I'd love to make sure these folks are not hindered from upgrading to the latest versions of Next!Beta Was this translation helpful? Give feedback.
All reactions