---
title: "Email verification in a Playwright test — YoAgent"
description: "A Playwright test that signs up with a fresh inbox, waits for the confirmation email and follows its link."
url: "https://yoagent.dev/recipes/playwright-email-verification"
---

[YoAgent](https://yoagent.dev/)

- [Use cases](https://yoagent.dev/#use-cases)
- [Web client](https://yoagent.dev/#dashboard)
- [Connect](https://yoagent.dev/#connect)
- [API & webhooks](https://yoagent.dev/#api)
- [Pricing](https://yoagent.dev/#pricing)
- [FAQ](https://yoagent.dev/#faq)
- [Contact](https://yoagent.dev/contact)

[Contact](https://yoagent.dev/contact)[Sign in](https://dashboard.yoagent.dev/login)[Start free](https://dashboard.yoagent.dev/login)

Recipe

# Email verification in a Playwright test

Your sign-up sends a confirmation link. This test signs up with a fresh address, waits for the email, checks the link goes to your app and opens it. Each run gets its own inbox and deletes it at the end.

## 1. A key for CI

In the [dashboard](https://dashboard.yoagent.dev/), create an API key for one project with these permissions:`inbox_create`, `inbox_delete`, `message_read`. Put it in your CI's secrets as `YOAGENT_KEY`.

## 2. The test

Change `/signup`, the form's selectors, the email's subject and the confirmation text to your app's. The inbox is new on every run, so an older email never passes for this one.

**Test**

tests/signup.spec.ts

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

const yo = async (path: string, init?: RequestInit) => {
  const response = await fetch(`https://api.yoagent.dev/v0${path}`, {
    ...init,
    headers: {
      Authorization: `Bearer ${process.env.YOAGENT_KEY}`,
      "Content-Type": "application/json",
    },
  });
  if (!response.ok) throw new Error(`${path}: ${response.status}`);
  return response.status === 204 ? null : response.json();
};

test("sign-up sends a working link", async ({ page, baseURL }) => {
  test.setTimeout(90_000); // the wait below takes up to 60 s
  const inbox = await yo("/inboxes", { method: "POST", body: "{}" });
  try {
    await page.goto("/signup");
    await page.fill("#email", inbox.address);
    await page.click("text=Create account");

    const query = new URLSearchParams({
      to: inbox.address,
      after: inbox.created_at,
      subject: "Confirm your email", // part of your email's subject
      timeout: "60",
    });
    const { message } = await yo(`/messages/wait?${query}`);
    expect(message, "no email within 60 s").toBeTruthy();
    const app = new URL(baseURL!).origin;
    const verify = message.links.find(
      (link) => link.kind === "verify" && new URL(link.url).origin === app,
    );
    expect(verify, "no verify link to the app in the email").toBeTruthy();
    await page.goto(verify.url);
    await expect(page.getByText("Email confirmed")).toBeVisible();
    expect(new URL(page.url()).origin, "confirmed off the app").toBe(app);
  } finally {
    await yo(`/inboxes/${inbox.inbox_id}`, { method: "DELETE" }).catch(console.warn);
  }
});
```

The app's address comes from the config:

**Config**

playwright.config.ts

```ts
import { defineConfig } from "@playwright/test";

export default defineConfig({
  use: { baseURL: process.env.APP_URL ?? "http://localhost:3000" },
});
```

## 3. Run it

**Shell**

Command

```bash
APP_URL=http://localhost:3000 npx playwright test signup
```

`APP_URL` is where your app runs;`YOAGENT_KEY` comes from your CI's secrets (locally, export it first). The wait takes up to 60 seconds; when no email comes, the test fails with "no email within 60 s".

© 2026 Aura AI Solutions, LLC

- [Playwright recipe](https://yoagent.dev/recipes/playwright-email-verification)
- [API (OpenAPI)](https://yoagent.dev/openapi.json)
- [llms.txt](https://yoagent.dev/llms.txt)
- [Terms](https://yoagent.dev/terms)
- [Privacy](https://yoagent.dev/privacy)
- [Refunds](https://yoagent.dev/refund)
- [Contact](https://yoagent.dev/contact)
- <support@yoagent.dev>
