Replies: 5 comments 2 replies
-
From @kettanaito from the POV of MSW: On whether the Next's instrumentation hook helps:
On fetch patching in DEV:
On overall needs for Next and MSW integration:
|
Beta Was this translation helpful? Give feedback.
-
Happy to see this proposal being brought up. One important aspect that I also shared in #52520, is that API mocking transcends the use cases for testing, as people are also using it for development and debugging. This is why I find the Instead of focusing inward on Next, as in adding support for testing capabilities within Next, I highly encourage the team to think outward, and instead provide versatile implementation from Next to the third-party consumers. I believe that the The expected order to support third-party API mocking libraries that exclusively rely on patching request-issuing modules would be the following:
If that would be the case, then third-party libraries would be able to do their job and enable API mocking for any use case with Next: development, testing, debugging, etc. It is simply a more versatile approach and, potentially, even more concise one. |
Beta Was this translation helpful? Give feedback.
-
I'm working on a |
Beta Was this translation helpful? Give feedback.
-
Reliable, documented testing practices for API mocking with next app router would be wonderful. It's hard to justify adopting the framework for larger projects without this. |
Beta Was this translation helpful? Give feedback.
-
Bumping this, any updates? |
Beta Was this translation helpful? Give feedback.
-
Goals
Non-Goals
Background
There are many ways to test Next applications, such as using Jest or other test runners. However, these tests have to mock away Next APIs and workflows. This approach works well for many tests, but it's missing deeper integration testing with Next. This is especially relevant for App Router.
Proposal
Consider
next test
command that would enable:next/navigation
,next/headers
, and so on.A lot of nuances for the test runner are still TBD:
Context:
Beta Was this translation helpful? Give feedback.
All reactions