Testing a full-stack app with Cypress.io


I’m working on a full-stack NestJS application, integrating with Auth0 using the https://github.com/auth0/express-openid-connect connect library. I’m using Cypress for e2e tests, and I’m trying to find a way of testing my login using Cypress.

I found this article - End-to-End Testing with Cypress and Auth0, but it seems to be very much tied to a React application. I’m calling the /oauth/token API endpoint, and I get a response, but I’m unsure how to build out my callback URL to log me in to the application. Here’s what I have so far:

Cypress.Commands.add('login', () => {
  cy.session('logged in user', () => {
    const options = {
      method: 'POST',
      url: `${Cypress.env('OAUTH_DOMAIN')}/oauth/token`,
      body: {
        grant_type: 'password',
        username: Cypress.env('AUTH_USERNAME'),
        password: Cypress.env('AUTH_PASSWORD'),
        scope: 'openid profile email',
        audience: `${Cypress.env('OAUTH_DOMAIN')}/api/v2/`,
        client_id: Cypress.env('OAUTH_CLIENT_ID'),
        client_secret: Cypress.env('OAUTH_CLIENT_SECRET'),
    cy.request(options).then((response) => {
      // What do I do here?

Any pointers would be gratefully recieved!

I managed to sort this out using Puppeteer - full solution for future Googlers is on Stack Overflow here oauth - Testing authentication with Auth0 in a full stack application with Cypress - Stack Overflow