# End-to-End Testing with Cypress and Auth0

**URL:** <https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082>\
**Category:** Get Help\
**Created:** [December 14, 2018, 1:35pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082 "2018-12-14T13:35:04Z")\
**Posts on this page:** 1\
**Showing post:** 111

<div class="post-metadata">

**Author:** ![Hawxy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hawxy/32/21395_2.png) [@Hawxy](https://community.auth0.com/u/Hawxy)\
**Post date:** [May 2, 2022, 4:12am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/111 "2022-05-02T04:12:23Z")

</div>

Cross-origin support is finally released which should resolve all remaining problems in this space:

> **[Cypress 9.6.0: Easily test multi-domain workflows with cy.origin](https://www.cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/)**
>
> Today we’re proud to introduce a feature a lot of Cypress users have been asking
> for: testing multiple superdomains in a single test! With the experimental 
> cy.origin() command, new in Cypress...

Here’s an example implementation for an Auth0 site that uses identifier-first login & automatically redirects on load:

```auto
Cypress.Commands.add('loginAsUser', (email, password) => {
    const args = { email, password }
    cy.session(
        args,
        () => {
            // visit homepage
            cy.visit('/')
            // redirects to Auth0
            cy.origin('/ **YOUR AUTH0 DOMAIN HERE** /', { args }, ({ email, password }) => {
                cy.get('#username').type(email)
                cy.get('button').contains(/^Continue$/).click();
                cy.get('#password').type(password)
                cy.get('button').contains('Continue').click();
            })
            // assert we've returned to the site
            cy.url().should('contain', '/home')
        }
    )
})

```

Very simple!

---

_[View the full topic](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082)._
