Joel
Joel3mo ago

TRPC with MSW

Does anyone have a basic example on how to set up MSW in a React Vite TRPC env? My main question is, how to use MSW to mock my TRPC requests. In a non TRPC environment my handlers looks like this:
http.get(`/api/my-svc/foo`, () => {
return HttpResponse.json(mockedResponse, { status: 200 });
}),
http.get(`/api/my-svc/foo`, () => {
return HttpResponse.json(mockedResponse, { status: 200 });
}),
But TRPC request looks different than a standard fetch request:
http://localhost:3003/rpc/mysvc.getFooData
http://localhost:3003/rpc/mysvc.getFooData
How do I create a handler to mock this TRPC request?
0 Replies
No replies yetBe the first to reply to this messageJoin