simulacrum icon indicating copy to clipboard operation
simulacrum copied to clipboard

Cypress version 11+ integration

Open MarkAPhillips opened this issue 2 years ago • 11 comments
trafficstars

In relation to https://github.com/thefrontside/simulacrum/tree/v0/integrations/cypress

Would it possible to upgrade the documentation and code to align with the latest version of cypress 11.2?

I am currently reviewing your package and am looking at integrating it with cypress to simulate Auth0.

As I progress am happy to post my findings here if that if of help as assume this is possibly already on your roadmap.

MarkAPhillips avatar Nov 25 '22 08:11 MarkAPhillips

FYI I have managed to get this working now with the latest version of Cypress (browser) and will post some updates here later - key aspect was to create a cypress.config.ts (if using typescript)

import { defineConfig } from 'cypress';
import { encrypt } from '@simulacrum/auth0-cypress/encrypt';

export default defineConfig({
  e2e: {
    baseUrl: 'http://localhost:3000',
    setupNodeEvents(on, config) {
      // implement node event listeners here
      on('task', { encrypt });
    },
    env: {
      audience: 'xxxx',
      domain: 'localhost:4400',
      clientID: 'xxxx',
      connection: 'Username-Password-Authentication',
      scope: 'openid profile email',
    },
  },
});

MarkAPhillips avatar Nov 28 '22 09:11 MarkAPhillips

@MarkAPhillips thank you for raising this. Do you feel comfortable raising a PR to increase the cypress version?

dagda1 avatar Nov 28 '22 11:11 dagda1

Yes sure @dagda1 - but let me do some further investigations

MarkAPhillips avatar Nov 28 '22 11:11 MarkAPhillips

@MarkAPhillips awesome! You have all the time you need

dagda1 avatar Nov 28 '22 11:11 dagda1

Please note Cypress has now be updated to version 12 so will look into this now

MarkAPhillips avatar Dec 15 '22 10:12 MarkAPhillips

@MarkAPhillips great stuff, let me know if there is anything I can do.

dagda1 avatar Dec 15 '22 10:12 dagda1

A few things I have noticed when upgrading to version 12 is that I received this error: Cypress.Cookies.defaults() has been deprecated and is no longer supported - I am not sure where this is being used unless it relates to the cy.clearCookies command in the logout

Another point of note was that we are using Apollo client which was running a different version of graphql to that used by the auth0 simulator - so initially received an error as you cannot run two versions - so had to override this in the package.json

"overrides": { "@simulacrum/auth0-simulator": { "graphql": "16.6.0" } },

MarkAPhillips avatar Dec 16 '22 10:12 MarkAPhillips

@MarkAPhillips upgrading the dependencies is the right thing to do.

dagda1 avatar Dec 17 '22 11:12 dagda1

@dagda1 reviewing this again now - it seems the issue is that in this file https://github.com/thefrontside/simulacrum/blob/302ff9540612fb58730c1ed4c412d2ff09394134/integrations/cypress/cypress/support/utils/whitelist-cookies.ts - Cypress now recommend using cy.session for these scenarios

Do you have a preferred approach as the version of Cypress you are using is very much out of date - I have cloned this repository and will start to review upgrading Cypress to the latest - Cypress also recommend this approach - https://docs.cypress.io/guides/end-to-end-testing/auth0-authentication - for Cypress 12 - so might review this in line with changes in Cypress 12

What you'll learn

MarkAPhillips avatar Aug 09 '23 06:08 MarkAPhillips

Do you have a preferred approach as the version of Cypress you are using is very much out of date - I have cloned this

@MarkAPhillips I have no preferred approach and I very much look forward to see how you approach this

dagda1 avatar Aug 09 '23 07:08 dagda1

Please see my PR I just created which solves all of the above :+1:

JasonLandbridge avatar Sep 28 '23 13:09 JasonLandbridge