I’m currently using the
@auth0/auth0-react library to manage login and logout in my app, and it works great. However, I’m now looking to add automation tests to it and I’m looking for a way to fake logging in.
I did find a blog post at End-to-End Testing with Cypress and Auth0 which attempts to describe how to do this, but it doesn’t work with this library. Doing the login in the background, and then redirecting to the page as if it was an OAuth2 Implicit Grant simply does nothing. No errors, no network requests, and certainly not logged in.
It turns out that
@auth0/auth0-react uses PKCE, which is great. But this means that I also can’t just fake a redirect to
/?code=...&state=..., because the
state value needs to be present in the
a0.spajs.txs session storage object, and that also needs to store a valid
Is there a recommended way to automation test logging in when using
@auth0/auth0-react? Or should I rework with one of the other client libraries?
Edit: I should say that right now I’m driving the Auth0 login dialog, and have had to configure it to force login every time - with
prompt:"login". That’s not a great solution for a number of reasons, which is why I’m trying to find a better way to do this.