# How do I get the one time code for my E2E testing

Use Humanless to give the test user an address your test can read: create a disposable inbox before the login step, log in with that address, and call `waitForCode`, which returns the one-time code as soon as the email arrives. In Playwright, do this once in a setup project and save the session with `storageState`, so the other tests start already logged in and don't each wait for an email. With an auth provider such as Auth0, create the test user with the inbox address (through signup or the provider's management API) so the provider's email goes to an inbox you control.

```ts auth.setup.ts
import { test as setup } from "@playwright/test";
import { Humanless } from "humanless";

const hl = new Humanless({ apiKey: process.env.HUMANLESS_API_KEY! });

setup("log in once", async ({ page }) => {
  const inbox = await hl.createIdentity({ channels: ["email"], ttl_seconds: 3600 });
  await page.goto("/login");
  await page.getByLabel("Email").fill(inbox.email!);
  const since = Date.now();
  await page.getByRole("button", { name: "Continue" }).click();
  const { code } = await hl.waitForCode({ identityId: inbox.identity_id, since, timeout: 25 });
  await page.getByLabel("Code").fill(code);
  await page.getByRole("button", { name: "Continue" }).click();
  await page.context().storageState({ path: "playwright/.auth/user.json" });
});
```

## Other options

- **Mailpit** if your test environment can send through your own SMTP server.
- **A password-based test user** in a test tenant, with passwordless kept for one dedicated test.
- **Hosted inboxes** such as Mailosaur or MailSlurp, or a Gmail mailbox read through the Gmail API.

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

More: [How to test email OTP and verification codes in Playwright](/guides/playwright-email-otp) · [All answers](/answers/)

Last updated 2026-12-04

Canonical: https://usehumanless.com/answers/how-do-i-get-the-one-time-code-for-my-e2e-testing

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