Cypress Testing with SPA + Custom API (getTokenSilently function not working in Cypress)

Hello all :slight_smile:

Where I’m At

We are working on a project that is a React webapp that uses Auth0 to authenticate users. Also, we have a custom api setup in order to make request to the backend.

The issue

I am running issues with setting up Cypress testing for this project. I finally able to log in as a user by following this github: “https://github.com/dunson062786/login-programmatically-into-auth0-with-cypress”, however i am getting “HTTP error 401 Unauthorized” when I am trying to make request.

I need to make some changes to the auth_audience in order to make the cypress logged in. I am not sure if that is the reason is breaking the getTokenSilently function.

Below are the part that I changed in order for the Cypress stay logged in. I changed the audience to custom API audience instead of default (which is system API). I provide the cypress.env.json and auth_config.json for reference purpose.

When I console log the system browser shows that ‘isAuthenticated’ is true, however the token is undefined.

Thank you for your time reading it, any help will be greatly appreciated! :pray: