# How to test magic links in CI

In CI, Humanless gives each run a unique inbox, so you don't need a mail server in the pipeline: create an identity, request the magic link with its address, call `waitForLink` (it returns the sign-in URL as soon as the email lands), open the URL in the same headless browser context, and assert the session. Store `HUMANLESS_API_KEY` as a CI secret. Because every test gets its own address, parallel jobs and retries can't consume each other's single-use links. Keep the link wait shorter than your test timeout, and delete the identity in teardown. Pay-as-you-go accounts can create 30 identities per hour (Starter 100, Team 300, Scale 1,000), so for larger suites reuse an identity across a spec or save the login state.

```yaml .github/workflows/e2e.yml
- name: E2E tests
  run: npx playwright test
  env:
    HUMANLESS_API_KEY: ${{ secrets.HUMANLESS_API_KEY }}
    BASE_URL: https://staging.example.com
```

```ts magic-link.spec.ts
const since = Date.now();
await page.getByRole("button", { name: "Email me a link" }).click();
const { url } = await hl.waitForLink({ identityId: identity_id, since, timeout: 25 });
await page.goto(url);
await expect(page.getByTestId("avatar")).toBeVisible();
```

## Other options

- **Mailpit as a CI service container** (ports 1025 and 8025), with your app's SMTP pointed at it.
- **Generate the link server-side** with an admin API, such as Supabase's `auth.admin.generateLink()`, for tests that don't need the email.
- **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-test-magic-links-in-ci

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