Email confirmation is a critical step in many signup flows — but it’s often left out of automated testing due to complexity or slow third-party tools. And when it is tested, it's often through workarounds — mocking email services, bypassing confirmation links, or verifying only backend state.
This guide shows how to test the entire registration flow, including real email confirmation, using Playwright and temporary inboxes created with Tigrmail. You'll get a working test in minutes and a clean way to automate email-based flows.
You can try this locally using the full example repo:
👉 https://github.com/furionix-labs/playwright-email-verification-example
🔧 What We’re Testing
- Create a temporary inbox
- Sign up using that email
- Wait for a verification email
- Extract the confirmation link
- Visit the link to confirm the account
🛠 Setup
Clone the example repository:
git clone https://github.com/furionix-labs/playwright-email-verification-example.git
cd playwright-email-verification-example
Install dependencies:
npm install
Create a .env
file:
cp .env.example .env
And add your Tigrmail API token. You can get one at console.tigrmail.com.
▶️ Running the Test
Once your .env
is ready, run the test:
npx playwright test
This will open the browser, fill in the form, wait for a real confirmation email, extract the link, and visit it — just like a real user would.
🧪 Test Example (signup.spec.ts)
import { test, expect } from '@playwright/test';
import { Tigrmail } from 'tigrmail';
import * as dotenv from 'dotenv';
import * as cheerio from 'cheerio';
// Helper function to extract the first link from an email HTML
function extractFirstLink(html: string): string | null {
const $ = cheerio.load(html);
const firstHref = $('a').first().attr('href');
return firstHref ?? null;
}
// Load environment variables from .env file
dotenv.config();
const TIGRMAIL_TOKEN = process.env.TIGRMAIL_TOKEN;
test('user can sign up and verify email', async ({ page }) => {
// Fail fast if token is not set
if (!TIGRMAIL_TOKEN) {
throw new Error('Set TIGRMAIL_TOKEN in .env');
}
// Create a disposable email inbox
const tigr = new Tigrmail({ token: TIGRMAIL_TOKEN });
const emailAddress = await tigr.createEmailAddress();
// Go to the registration page
await page.goto('/sign-up');
// Fill in the registration form
await page.getByTestId('email-input').fill(emailAddress);
await page.getByTestId('password-input').fill('TestPassword123!');
await page.getByTestId('password-confirm-input').fill('TestPassword123!');
// Submit the form
await page.getByTestId('submit-btn').click();
// Verify that the app prompts user to confirm their email
await expect(page.getByTestId('verification-status')).toHaveText(
'Your email is not verified. Please check your inbox for the verification email.'
);
// Wait for the verification email to arrive
const message = await tigr.pollNextMessage({ inbox: emailAddress });
// Extract the verification link from the email
const verificationLink = extractFirstLink(message.body);
if (!verificationLink) {
throw new Error('No <a> tag with href found in the email body');
}
// Visit the verification link
await page.goto(verificationLink);
await page.waitForSelector('text=Your email has been verified');
// Go back and check that the verification status has changed
await page.goBack();
await expect(page.getByTestId('verification-status')).toHaveText('Your email is verified!');
});
This is a full E2E test — no mocking, no shortcuts.
💡 Why Tigrmail?
Tigrmail is designed specifically for testing email-based workflows. It offers:
- Fast and isolated temporary inboxes
- Filtering by subject, sender, or domain
- Automatic polling with retry logic
- Generous limits — up to 3,000 inboxes per month
- A simple Node.js SDK for easy integration
And it’s not limited to signup flows — you can test password resets, magic links, 2FA codes, onboarding emails, marketing messages, or anything else your app sends.
Compared to other email testing APIs, it's lightweight, focused, and affordable — and completely free to try until September 1st, 2025.
So if you're wondering whether email automation is worth adding to your tests — now is a great time to experiment and decide.
✅ Final Thoughts
Email flows are a real part of your app — so they should be a real part of your tests.
With Playwright and temporary inboxes, you can automate this without relying on hacks or skipping critical paths.
If you're testing registration, password resets, or anything involving email links — this setup works out of the box.
Repo again: https://github.com/furionix-labs/playwright-email-verification-example
Top comments (0)