Test example for react-testing-library
Does trpc has any example of doing tests with react-testing-library? We need to wrap the app using
trpc.withTRPC
.
The docs doesn't have a section refering to test, just an example of using context inner
, but that also doesn't work in case we actually need to have the req
or the res
in the context (in NextJS context), for example, to set cookies, etc.
Would be welcome to add a section about testing and how to wrap components with react testing library and actually run tests where we actually need the next req, res in the context? (It might not be necessary to have the entire req,res in the context but utility to set cookies in the response to handle auth, for example, etc)
A few screenshots:![](https://utfs.io/f/2ac63ba0-3696-4d8e-a3ef-154cb4965f8e-4pl4mu.png)
![](https://utfs.io/f/a3363830-d2a9-4483-864d-d63190bc4df5-4pl4mu.png)
2 Replies
up
i don't mock responses
i prefer running an actual server with a real db