gatsby-theme-auth0 icon indicating copy to clipboard operation
gatsby-theme-auth0 copied to clipboard

Impossible to automate testing

Open dandv opened this issue 4 years ago • 1 comments

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.

dandv avatar Jun 29 '20 23:06 dandv

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

insuusvenerati avatar Jul 11 '20 17:07 insuusvenerati