Custom auth0 login command fails in CI
With the new release of v9.6.0 and the new cy.session and cy.origin, along with multiple guides (guide 1, guide 2), I tried updating our Cypress tests to run using the new functionality. While I was able to run the commands locally, they would always fail on GitHub Actions. From the videos and screenshots, it looks like whenever the login command would run and redirect to auth0, the app would crash. I thought the issue might be with the app itself, but the tests ran successfully on Circle CI.
Stack used:
- Cypress 9.7.0
- Node v14
- Chrome (headed)
- Ubuntu-20
The command in question:
Cypress.Commands.add('loginAsUser', (email, password) => {
const args = { email, password };
cy.session(args, () => {
// visit homepage
cy.visit('/');
cy.get('button[data-cy=login]').click();
// redirects to Auth0
cy.origin('AUTH0_DOMAIN', { args }, (args) => {
cy.get('#username').type(args.email);
cy.get('#password').type(args.password);
cy.get('button')
.contains(/^Continue$/)
.click();
});
// assert we've returned to the site
cy.get('h6[data-testid=clock]').should('exist');
cy.get('button[data-cy=logout-button]').should('exist');
});
});
The output on Github Actions:
The command was expected to run against origin https://auth0.com but the application is at origin `chrome-error://chromewebdata`.
This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.
Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Login Behaviour`
at Object.eval [as setup] (http://localhost:5000/__cypress/tests?p=cypress/support/index.js:38433:8)
Hi @bunge12, have you solved this issue? If yes, could you please share the solution?
Hi @Artem-Bosenko-01, we opted to run Cypress on CircleCI and it runs without any issues using the command from above.
Closing, since a workaround was found.