# How to automate email verification on E2E testing?

Use Humanless to register each test user with an address the test can read, then follow the verification link the app sends. Create a disposable inbox (here in a Cypress `cy.task`; Playwright, Selenium and plain HTTP work the same way), sign up with it, take a timestamp just before submitting, and wait with `waitForLink`, which returns the "verify email" URL already picked out of the message. Then visit the URL and assert the account is verified. Your app sends through its normal mail provider, so the test covers the same path your users get. If the link points at a different origin, such as a hosted identity provider, wrap the visit in `cy.origin`.

```ts verify-email.cy.ts
// Tasks (createInbox, waitForLink, deleteInbox): see /answers/how-to-read-emails-in-cypress
cy.task("createInbox").then(({ identity_id, email }: any) => {
  cy.visit("/signup");
  cy.get("input[name=email]").type(email);
  cy.get("input[name=password]").type("correct-horse-battery");
  cy.then(() => {
    const since = Date.now();
    cy.get("button[type=submit]").click();
    cy.task("waitForLink", { id: identity_id, since }).then((url) => cy.visit(String(url)));
  });
  cy.contains("Email verified").should("be.visible");
  cy.task("deleteInbox", identity_id);
});
```

## Other options

- **Mailpit** as the SMTP server in test environments, with the link read from its REST API.
- **Skip the step** for tests that aren't about verification: mark the user verified in your test database or through your auth provider's admin API. If you use Keycloak, that's `emailVerified: true` through the Admin REST API.
- **Hosted inboxes** such as Mailosaur or MailSlurp.

> **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/how-to-automate-email-verification-on-e2e-testing

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