# I am trying to use Cypress to automate a login for an app that uses Auth0, Next.js and passwordless

Humanless gives your Cypress test an inbox it can read, which Auth0 passwordless email needs because Auth0 sends the code or link. Per run: create a disposable inbox in a `cy.task`, enter its address on Auth0's Universal Login page inside `cy.origin("https://YOUR_TENANT.auth0.com", ...)`, then wait for the email with `waitForCode` (for an emailed code) or `waitForLink` (for a magic link) and complete the step. The app's callback then sets the Next.js session cookie as usual. Wrap it in `cy.session` so the email round trip happens once per spec, not once per test.

```ts auth0-passwordless.cy.ts
// Tasks (createInbox, waitForCode, waitForLink): see /answers/how-to-read-emails-in-cypress
const AUTH0 = "https://YOUR_TENANT.auth0.com";
cy.task("createInbox").then(({ identity_id, email }: any) => {
  cy.visit("/api/auth/login");
  const since = Date.now(); // taken before the code is requested
  cy.origin(AUTH0, { args: { email } }, ({ email }) => {
    cy.get("input[name=email]").type(email);
    cy.contains("button", "Continue").click();
  });
  cy.task("waitForCode", { id: identity_id, since }).then((code) => {
    cy.origin(AUTH0, { args: { code: String(code) } }, ({ code }) => {
      cy.get("input[name=code]").type(code);
      cy.contains("button", "Continue").click();
    });
  });
  cy.url().should("include", "/dashboard");
});
```

## Other options

- **Programmatic login** in a test tenant: Cypress's Auth0 recipe gets tokens through Auth0's API and skips the hosted page.
- **A database connection test user** with a password, enabled only in the test tenant, for tests that aren't about passwordless.
- **Mailosaur or MailSlurp** as the inbox.

> **Use policy:** Only for apps you own or are authorized to test. See the [Terms](/terms).

More: [How to test magic link login end to end](/guides/magic-link-testing) · [All answers](/answers/)

Last updated 2026-12-04

Canonical: https://usehumanless.com/answers/i-am-trying-to-use-cypress-to-automate-a-login-for-an-app-that-uses-auth0-nextjs

---
More: https://usehumanless.com/llms.txt
