# Testing email confirmation

Humanless lets an automated test confirm a signup through the real email: sign up with a disposable address, wait for the confirmation email with `waitForLink` (or `GET /v1/identities/:id/wait` over REST), and open the returned `url` in the same browser session. That covers what a database shortcut can't, such as a broken template, a wrong link host or mail that never leaves staging. Shortcuts still have their place: most tests can create users that are already confirmed, as long as at least one test goes through the real email.

```ts confirm-email.spec.ts
const inbox = await hl.createIdentity({ channels: ["email"] });
const since = Date.now();
await signUp(page, inbox.email!);                // your helper
const { url } = await hl.waitForLink({ identityId: inbox.identity_id, since, timeout: 25 });
expect(new URL(url).host).toBe("staging.example.com"); // catches links to the wrong environment
await page.goto(url);
await expect(page.getByText("Your email is confirmed")).toBeVisible();
await hl.deleteIdentity(inbox.identity_id);
```

## Other options

- **Set the confirmed flag in the database or through an admin API** for tests that aren't about confirmation.
- **Mailpit** to capture confirmation emails in local and CI environments.
- **A real test mailbox** read over IMAP or the Gmail API.

> **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/testing-email-confirmation

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