-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use trpc directly in playwright testing? #123
Labels
bug
Something isn't working
Comments
Playwright runs in a node environment, so you are unable to create a browser trpc client with trpc-sveltekit/package/src/client.ts Lines 64 to 80 in bb32593
If you want to test your endpoint, you will need to manually create a client with import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
const client = createTRPCProxyClient({
links: [httpBatchLink({ url: "..." })],
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: