lukas
lukas2y ago

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:
2 Replies
lukas
lukas2y ago
up
Alex / KATT 🐱
i don't mock responses i prefer running an actual server with a real db