Auth0 login is working in app mode but in headless mode is not #24281
Unanswered
fjpedrosa
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I think this error might be common to some other discussions that are open, thats why I consider it something important to understand why it is happening.
I have a React app with Auth0 for users management. Implemented a custom command for authentication as explained here with the only difference of the localstorage item name, (because I am storing the token in localstorage and it is neccessary to have a specific name). Here you can see this approach
Cool, everything working in the app when using chrome.This is the login code:
before(() => { cy.login() cy.visit('/') cy.saveLocalStorage() })
then I only need to persist the localstorage between tests. However, when I run the test in headless mode, using chrome (--headless --browser chrome) the tests are not passing. When I see the screenshots and the video I realize that while before, the cy.visit() ends up in the home page (this is what it is expected when the user has a valid token), in this case the user is redirected to the login page, thats why a timeout happens.
I then tested with the application using electron and found the same behavior as with the headless mode.
I validated that the token is already stored in localStorage before running cy.visit('/), and it is, so it looks like the cy.visit('/') command in headless mode is not taking the token from localstorage.
I would be updating here any finding I have. Also any help is appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions