tRPCttRPC
Powered by
Jordan (UNCVRD)J
tRPC•3y ago
Jordan (UNCVRD)

Unable to mock unstable_batchStreamLink network response

Hi there! I have a couple API endpoints that call third party dependencies and would like to mock a network response for these calls during my playwright tests. I've been using
batchHttpLink
batchHttpLink
previously and mocking the following API route worked perfectly:

const deleteOrganization = page.route(endpointPath("authed.organization.delete"), (route) =>
            route.fulfill({
                status: 200,
                body: JSON.stringify([
                  { result: { data: { json: { success: true } }, meta: { values: {} } } },
                ]),
                headers: { 'Content-Type': 'application/json' },
              })
        )
const deleteOrganization = page.route(endpointPath("authed.organization.delete"), (route) =>
            route.fulfill({
                status: 200,
                body: JSON.stringify([
                  { result: { data: { json: { success: true } }, meta: { values: {} } } },
                ]),
                headers: { 'Content-Type': 'application/json' },
              })
        )


However when I use
unstable_batchStreamLink
unstable_batchStreamLink
this returns an error stating
Unexpected non-whitespace character after JSON at position 55
Unexpected non-whitespace character after JSON at position 55
which kinda makes sense because it should be streaming a response back instead of immediately receiving a JSON object. But I'm kind of stumped on how I can update my mock response call to satisfy TRPC to return that streamed data instead?

Anyone have insight on how to handle this? Thanks a lot for your time!
image.png
image.png
image.png
image.png
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

TRPC Client: Unable to transform response
Answer OverflowAAnswer Overflow / ❓-help
2y ago
TRPCClientError: Unable to transform response from server
Luiz F. A. MoraisLLuiz F. A. Morais / ❓-help
2y ago
TRPCClientError: Unable to transform response from server
2035Builder22035Builder / ❓-help
2y ago
TRPCClientError: Unable to transform response from server
Wojciech MorawskiWWojciech Morawski / ❓-help
3y ago