Auth0 Home Blog Docs

End-to-End Testing with Cypress and Auth0


Learn how to programmatically authenticate against Auth0 in your Cypress tests in a manner that adheres to both Cypress and Auth0 best practices…

Read more at:


How did you like this post? Please share any comments or feedback with us on this thread :slight_smile:


Really great guide, got me running with auth0 authentication perfectly, but this could be an issue when adding more tests due to the api rate limit at auth0.

I have a conditional in the before() hook of my tests to check if I’m logged in by checking existence of an access-token. So posting to auth_url to login happens once during my tests.

But hitting /callback uses up the request callback too, so whats the recommended way to not use /callback at the start of every test?

I did manage to stub the response that was taking up most of the API rate limit, it was running a GET request to /userinfo, I ran the get once and stored the response to be stubbed later. A guide on how to stub responses:


@bruno.krebs Great write up. That said, I’m looking for details on how to handle testing inviting users to my application through Cypress and Auth0. The workflow goes like this:

  1. As a privileged user, I invite someone to my application via their email
  2. The backend of my application sends them an invite
  3. The invite link goes to my landing page with the invitation key placed into sessionStorage
  4. The landing page redirects to my Auth0 provider, which of course I am bypassing with cy.request()

The only step I cannot automate is from step 2 to step 3. Is there a way to get the invitation key without causing security issues?


Thanks for the write-up! One question, though: my back-end server callback expects a code rather than an access_token. How can I get a code in the first request?