# Integration testing passwordless authentication with Playwright

Humanless handles the email half of a passwordless test: create a disposable inbox, request the magic link on your login page, and call `waitForLink`, which returns the sign-in URL already picked out of the email (it skips logo, help and unsubscribe links and decodes HTML entities). Open that URL with `page.goto(url)` in the same page that requested it, because PKCE verifiers and state cookies live in that browser context. Record `Date.now()` before the click and pass it as `since`, since a second request usually invalidates the first link. If your app sends a one-time code instead, use `waitForCode`.

```ts magic-link.spec.ts
await page.getByLabel("Email").fill(email!);
const since = Date.now();
await page.getByRole("button", { name: "Email me a sign-in link" }).click();
const { url } = await hl.waitForLink({ identityId: identity_id, since, timeout: 25 });
await page.goto(url); // same page, same context
await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible();
```

## Other options

- **Mailpit**: read the newest message for the address and match your own auth route in the HTML, not the first link.
- **Generate the link server-side**: Supabase's `auth.admin.generateLink()` and similar admin APIs return a sign-in link without sending email.
- **Firebase Auth emulator**: lists pending email-link codes at `/emulator/v1/projects/{project}/oobCodes`.

> **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/integration-testing-passwordless-authentication-with-playwright

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