Better-auth and e2e tests
Hello,
So I've encountered a difficulty creating fake users for e2e testing in playwright. I dont know how to generate fake token to add to the cookies. I've inspected the valid cookie with an account logged in normally and it seems like its just a
session token + "." + some string in the end
, ex: 123abc.123abc
, but I have no idea how to generate that string. I would guess that its based on the secret. Thats what I've tried:
I've also searched the docs for some examples or maybe methods to generate it, but no luck. Anyone knows what to do?Solution:Jump to solution
instead of strong the token from the response, parse the setCookie header and use that instead.
```ts
await authClient.signUp.email({}, {
onSuccess: (ctx)=>{...
4 Replies
Solution
instead of strong the token from the response, parse the setCookie header and use that instead.
Hello, sorry to bother. I'm wondering how to achieve the same result with social provider?
It's harder to test social providers unless you mock their response. In which case you can do the same thing but in
/callback/:providerId
path instead.Thanks! But I end up using this one: