I am using Cypress for E2E testing and Auth0-React. Currently I am programmatically logging into the app I need to test in my Cypress project. I use a PKCE flow to get a auth0 token to login, and then store that token in local storage. That is all working great, but here is my issue, in the app, we use the auth0-react library for dev/prod login and it stores user info in a user object. When I am using Cypress auth0-react is not being used so the user object is undefined. However, we rely on that user object throughout a lot of the app, so I would have to check for if there’s a token in local storage, parse it, and such everywhere we use it. Is there an easier way? I’ve looked all over but haven’t found anything. TIA
Hey there @KimberlyRamirez welcome to the community!
Hmm that’s a bit tricky not using auth0-react at all - From what I’ve seen testing typically looks like what is outlined in this blog post using auth0-react. That being said, in your environment perhaps you could just mock the user object? I have definitely seen this done as well.
Keep us posted?
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.