gatsby-theme-auth0
gatsby-theme-auth0 copied to clipboard
Impossible to automate testing
I've trying with Cypress to test a Gatsby using this theme. After getting a JWT programmatically from Auth0, I'm storing storing that in localStorage per this Cypress recipe.
Initially, { isLoggedIn } = useAuth()
returns true correctly because it looks in localStorage
, but after that, the useEffect
in useAuth()
calls checkSession
, which will fail, and will delete isLoggedIn
, effectively logging the user out.
I worked around this issue by setting localStorage.setItem('postLoginUrl', 'https://localhost:8000')
in the first then of the login command in cypress. Then setting localStorage.setItem('isLoggedIn', 'true')
in onBeforeLoad
in the cy.visit()
command.
This works in local development of course but I haven't gotten around to setting it up for CI