'Best way to mock authenticated (auth0) API calls in Cypress

I have a regular single page application (Vue), which authenticate via auth0 and generates a token which is validated by the backend on API calls.

I would like to test the vue application using cypress.

There are various "official" strategies (i.e. log in for every call or using a session and logging in once).

https://auth0.com/blog/end-to-end-testing-with-cypress-and-auth0/ https://docs.cypress.io/guides/testing-strategies/auth0-authentication

I could find only one resource about stubbing the auth0, instead of actually sending requests for tokens - https://github.com/auth0/auth0-spa-js/issues/210 .

I reached the above link by following another Stackoverflow post - How to test single page application with Cypress and Auth0 .

I have only little experience, but the stubbing solution seems closer to the best practices of test driven development.

I wanted to ask why it seems much less popular and if I miss the actual reasons behind the "actual auth0 call" options.

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source