Since writing this gist, sir-dunxalot/cypress-nextjs-auth0 was released, which encapsulates this gist in a more user-friendly way. Try it out:
yarn add cypress-nextjs-auth0 --dev
A walkthrough is covered in this blog post.
- You need to enable the
password
grant type in your Auth0 application's settings - You need to set the default directory (in your Auth0 tenant settings) to
Username-Password-Authentication
, which is usually the name of the database connection you want to use forpassword
grant authentication (the name will be shown in Auth0 Dashboard --> Connections --> Database). - The username and password combination should be a real user (albeit one you create for testing only)
- This method skips token verification and reveals secrets, but I am assuming I can reduce security in my test environment
- Auth0 recommends you use seperate tenants for development, testing, and production
- If this setup fails, you may need to add
"chromeWebSecurity": false
to yourcypress.json
config file.
I have the same issue as @dchoigt