Replies: 1 comment 1 reply
-
I'm also a Testing Library maintainer, and I suggested we request a Next.js API for this. Thanks for starting the discussion @Gpx! I think the currently suggested name of Until then, it would still be useful for us to have API feedback from the Next.js team. I'm mostly interested in knowing if this would be easy enough to support in Next.js, and if there are any suggested changes to make it easier to adapt to different renderers and meta frameworks (including other RSC servers) in tests. |
Beta Was this translation helpful? Give feedback.
-
Goals
In the @testing-library repository, we're discussing how to support Next's RSC in React Testing Library. See testing-library/react-testing-library#1209
One thing that would help us is having a method exposed by Next that, given a URL, returns a React component that renders the whole route tree.
For example, given this folder structure:
If I call
routeComponent('/dashboard')
, I will get back a React component that renders the correct page with its layouts.Non-Goals
No response
Background
This feature is needed to make testing Next applications with RTL easy. The alternative is for the person writing the tests to define the whole route tree:
Compare this with:
The former is harder to write, error-prone, and does not reflect route changes in the tests.
Proposal
I'm not an expert in Next, but I'm happy to help if there's interest on your side.
Beta Was this translation helpful? Give feedback.
All reactions