Practice app: run your first email test without an app of your own
Every guide on this site tests a sign-up flow in your application, so nothing passes until your app is wired up and sends real mail to an AssertInbox address. The practice app removes that step. It is a small fake product with a sign-up form that emails a six-digit code and a confirmation link to the address you give it. You copy one of the tests below, run it, and see it pass in a few minutes.
It is not a real product. It has no accounts, no passwords and no data beyond the sign-up record described below. It only ever sends to AssertInbox addresses, from inside the same service, and it never sends mail anywhere else.
How it works
- Get a key at /start. It takes one click and needs no email address or card. Export
ASSERTINBOX_KEYandASSERTINBOX_NAMESPACE. - Sign up at /practice/signup with
<namespace>.<tag>@assertinbox.com, choosing any tag. Any other address, including one on another domain, is refused with apractice_address_onlyerror. - Read the email through the API. Its
otpfield holds the code andmagic_linkholds the confirmation link. Enter the code at /practice/verify, or open the link.
The rules are small and fixed so your test can rely on them. The code is valid for 15 minutes and works once. Five wrong codes lock the sign-up until you ask for a new code. Send a new code makes the old code and the old link stop working, and you can ask once every 30 seconds. The link is valid for 24 hours and works once. A confirmed or verified sign-up cannot be verified again. Each network address can make 20 sign-ups and resends per hour, and the mail counts towards your namespace's daily message limit.
Playwright Test
Download assertinbox.mjs and playwright-fixture.mjs from the client files page into your tests folder, save this as practice.spec.mjs and run npx playwright test practice.spec.mjs. The inbox fixture gives every test its own tag, so tests can run in parallel.
import { test, expect } from "./playwright-fixture.mjs";
const PRACTICE = process.env.PRACTICE_URL || "https://assertinbox.com";
async function signUp(page, email) {
await page.goto(PRACTICE + "/practice/signup");
await page.getByLabel("Email address").fill(email);
await page.getByRole("button", { name: "Create account" }).click();
await expect(page).toHaveURL(/\/practice\/verify/);
}
test("sign up and verify with the emailed code", async ({ page, inbox }) => {
await signUp(page, inbox.address("code"));
const code = await inbox.waitForOtp();
await page.getByLabel("Verification code").fill(code);
await page.getByRole("button", { name: "Verify", exact: true }).click();
await expect(page.getByRole("status")).toContainText("Your email is verified");
});
test("sign up and confirm with the emailed link", async ({ page, inbox }) => {
await signUp(page, inbox.address("link"));
const link = await inbox.waitForLink();
await page.goto(link);
await expect(page.getByRole("status")).toContainText("Your email is confirmed");
});
pytest with pytest-playwright
Put assertinbox.py and pytest_assertinbox.py next to your tests, add pytest_plugins = ["pytest_assertinbox"] to conftest.py, and save this as test_practice.py. The page fixture comes from pytest-playwright.
import os
import re
from playwright.sync_api import expect
PRACTICE = os.environ.get("PRACTICE_URL", "https://assertinbox.com")
def sign_up(page, email):
page.goto(PRACTICE + "/practice/signup")
page.get_by_label("Email address").fill(email)
page.get_by_role("button", name="Create account").click()
page.wait_for_url(re.compile(r"/practice/verify"))
def test_sign_up_and_verify_with_code(page, inbox):
sign_up(page, inbox.address("code"))
page.get_by_label("Verification code").fill(inbox.wait_for_otp())
page.get_by_role("button", name="Verify", exact=True).click()
expect(page.get_by_role("status")).to_contain_text("Your email is verified")
def test_sign_up_and_confirm_with_link(page, inbox):
sign_up(page, inbox.address("link"))
page.goto(inbox.wait_for_link())
expect(page.get_by_role("status")).to_contain_text("Your email is confirmed")
API only, with node:test
No browser needed. This file calls the practice API directly and uses the client file for the inbox. Run it with node --test practice.test.mjs on Node 18 or newer.
import { test } from "node:test";
import assert from "node:assert/strict";
import { AssertInbox } from "./assertinbox.mjs";
const PRACTICE = process.env.PRACTICE_URL || "https://assertinbox.com";
const inbox = new AssertInbox({
key: process.env.ASSERTINBOX_KEY,
namespace: process.env.ASSERTINBOX_NAMESPACE,
});
async function post(path, body) {
const res = await fetch(PRACTICE + "/practice/api/" + path, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body),
});
return { status: res.status, body: await res.json() };
}
test("sign up and verify with the emailed code", async () => {
const tag = inbox.uniqueTag("practice-code");
const email = inbox.address(tag);
assert.equal((await post("signup", { email })).status, 201);
const code = await inbox.waitForOtp(tag, { timeout: 20, retries: 2 });
assert.match(code, /^\d{6}$/);
assert.deepEqual((await post("verify", { email, code })).body, { verified: true });
assert.equal((await post("verify", { email, code })).status, 400, "a code works once");
await inbox.delete(tag);
});
test("sign up and confirm with the emailed link", async () => {
const tag = inbox.uniqueTag("practice-link");
const email = inbox.address(tag);
assert.equal((await post("signup", { email })).status, 201);
const link = await inbox.waitForLink(tag, { timeout: 20, retries: 2 });
const first = await fetch(link, { redirect: "manual" });
assert.equal(first.headers.get("location"), "/practice/welcome?status=confirmed");
const again = await fetch(link, { redirect: "manual" });
assert.equal(again.headers.get("location"), "/practice/welcome?status=invalid", "a link works once");
await inbox.delete(tag);
});
For AI agents
An agent connected to the MCP server can rehearse a whole sign-up test here before it touches your application. Give it the test_signup_flow prompt with the practice URL, or paste this instruction:
Use the AssertInbox MCP server's test_signup_flow prompt with
url = https://assertinbox.com/practice/signup
Create a test address, sign up with it, read the code and the link from the
email, finish the sign-up both ways, then delete the test emails.
See how to let your coding agent test email flows for the instructions to keep in your repository.
What it stores
A practice sign-up keeps the AssertInbox address, a hash of the code, a hash of the link token and a few counters and times, and it is deleted after 24 hours, like every message. Practice mail does not count as your first real use of AssertInbox in our own statistics: we keep it separate on purpose, so that the number of people who integrated a real application stays honest. Details are in the privacy policy.
Next steps
When the practice tests pass, point the same test at your own application: replace the practice URL and the selectors with yours. The guides cover Playwright, Cypress, Selenium, pytest and many other stacks, and Reliable email tests explains unique tags, retries and cleanup.