You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Unable to use trpc client in playwright tests
To Reproduce
Steps to reproduce the behavior:
Setup a sveltekit project with playwright enabled
Create a basic tRPC config with an endpoint
Try to directly call it from playwright
Expected behavior
The client should work as it does in Svelte files in the frontend
Additional context
I tried various methods to create the client in playwright:
I tried using it without args and it gave me an Calling createTRPCClient() on the server requires passing a valid LoadEvent argument
Maybe I'm supposed to use createCaller() with createContext() like we do in server load functions, but what do we pass to the createContext()?
Creating the client with { url: { origin: page.url() } } also doesn't seem to work and give this error: TRPCClientError: Unexpected token '<', "<!doctype "... is not valid JSON
The text was updated successfully, but these errors were encountered:
Playwright runs in a node environment, so you are unable to create a browser trpc client with trpc-sveltekit. It is missing the necessary context to know where to send the requests.
Describe the bug
Unable to use trpc client in playwright tests
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The client should work as it does in Svelte files in the frontend
Additional context
I tried various methods to create the client in playwright:
Calling createTRPCClient() on the server requires passing a valid LoadEvent argument
createCaller()
withcreateContext()
like we do in server load functions, but what do we pass to thecreateContext()
?{ url: { origin: page.url() } }
also doesn't seem to work and give this error:TRPCClientError: Unexpected token '<', "<!doctype "... is not valid JSON
The text was updated successfully, but these errors were encountered: