[Blog](https://mailforbots.com/blog)

# How to test password-reset emails in CI

Published October 12, 2026 · Updated October 12, 2026

Password reset is the flow nobody notices until it breaks, and then it is the only thing users notice. Here is a robust way to test it end to end in CI against a real inbox, with Playwright. The same shape works in Cypress or any runner.

## The shape of the test

1. Create a fresh inbox (auto-deleting).
2. Register a user with that address.
3. Trigger "forgot password".
4. Wait for the reset email, read the link.
5. Open the link, set a new password, log in.

Playwright (TypeScript)

```
import { test, expect } from "@playwright/test";

const API = "https://mailforbots.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.BOTMAIL_KEY}`, "Content-Type": "application/json" };

test("password reset email works", async ({ page, request }) => {
  // 1. a fresh inbox that deletes itself after 30 minutes
  const inbox = await (await request.post(`${API}/inboxes`, { headers, data: { ttl_minutes: 30 } })).json();

  // 2-3. register, then ask for a reset (your app's own steps)
  await page.goto("https://staging.example.com/signup");
  await page.fill("[name=email]", inbox.address);
  await page.fill("[name=password]", "Old-password-1");
  await page.click("text=Sign up");
  await page.goto("https://staging.example.com/forgot");
  await page.fill("[name=email]", inbox.address);
  await page.click("text=Send reset link");

  // 4. wait for the matching email (long-poll, up to 60 s)
  const res = await request.get(`${API}/inboxes/${inbox.id}/wait?subject_contains=reset&timeout_seconds=60`, { headers });
  expect(res.status()).toBe(200);
  const message = await res.json(); // the full message, with extracted codes and links
  const link = message.extracted.links.find((l) => l.kind === "reset")?.url ?? message.extracted.links[0].url;

  // 5. use it
  await page.goto(link);
  await page.fill("[name=password]", "New-password-2");
  await page.click("text=Save");
  await expect(page).toHaveURL(/dashboard/);
});
```

Field names follow the [REST reference](https://mailforbots.com/docs/rest); check the response shape for your plan in the docs when you adapt it.

## Make it reliable

- **One inbox per test.** Parallel runs then never see each other's mail.
- **Filter the wait.** `subject_contains` and `from_contains` stop an old message satisfying a new test.
- **Assert on timing.** Record how long the email took; alert when it drifts.
- **Test the unhappy paths.** Expired link, used link, unknown address (no email should arrive: assert the wait times out).
- **Keep the key in CI secrets** and give it a scope that only manages test inboxes ([API keys and scopes](https://mailforbots.com/docs/keys)).

Prefer to be called rather than poll? [Webhooks](https://mailforbots.com/docs/webhooks) fire the moment mail arrives. For the bigger picture see [how to QA email flows in 2026](https://mailforbots.com/blog/how-to-qa-email-flows-with-ai-2026).

[Start free](https://mailforbots.com/#/signup) [Read the quickstart](https://mailforbots.com/docs/quickstart)

## Related reading

- [Playwright email tests: OTP and magic links with a per-worker inbox fixture](https://mailforbots.com/blog/playwright-email-verification-otp-tests)
- [How to test sign-up and magic-link emails in Cypress](https://mailforbots.com/blog/cypress-email-verification-tests)
- [Disposable inboxes for testing sign-up and password-reset emails](https://mailforbots.com/email-testing-for-developers)
