Puppeteer + plop.email

Add email verification to your Puppeteer browser automation tests. Perfect for Node.js testing with headless Chrome.

Puppeteer Documentation

Features

Native Node.js

First-class JavaScript/TypeScript support with async/await.

Headless Chrome

Fast, efficient testing with Chrome's DevTools Protocol.

Screenshot & PDF

Capture visual evidence alongside email verification.

Network Interception

Mock and intercept network requests for isolated testing.

Setup

# Install Puppeteer
npm install puppeteer

# Or for just the core library (bring your own browser)
npm install puppeteer-core

# Add environment variable
echo "PLOP_API_KEY=your_api_key" >> .env

Basic Email Test

Test email flows with Puppeteer.

Basic Email Testtypescript
const puppeteer = require('puppeteer');

async function testSignupEmail() {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  const testEmail = `puppeteer+${Date.now()}@in.plop.email`;

  try {
    // Complete signup
    await page.goto('https://yourapp.com/signup');
    await page.type('[name="email"]', testEmail);
    await page.type('[name="password"]', 'SecurePass123!');
    await page.click('button[type="submit"]');
    await page.waitForSelector('.success-message');

    // Wait for email delivery
    await new Promise(r => setTimeout(r, 2000));

    // Fetch email via plop API
    const response = await fetch(
      `https://api.plop.email/v1/messages/latest?to=${testEmail}`,
      {
        headers: { Authorization: `Bearer ${process.env.PLOP_API_KEY}` }
      }
    );
    const email = await response.json();

    // Verify
    console.assert(email.subject.includes('Welcome'), 'Should have welcome subject');
    console.assert(email.htmlContent.includes('Get Started'), 'Should have CTA');

  } finally {
    await browser.close();
  }
}

testSignupEmail();

Email Link Navigation

Extract links from emails and navigate to them.

Email Link Navigationtypescript
const puppeteer = require('puppeteer');

async function testEmailVerificationFlow() {
  const browser = await puppeteer.launch({ headless: false });
  const page = await browser.newPage();
  const testEmail = `verify+${Date.now()}@in.plop.email`;

  // Trigger verification email
  await page.goto('https://yourapp.com/signup');
  await page.type('[name="email"]', testEmail);
  await page.type('[name="password"]', 'SecurePass123!');
  await page.click('button[type="submit"]');

  // Fetch verification email
  await new Promise(r => setTimeout(r, 3000));
  const response = await fetch(
    `https://api.plop.email/v1/messages/latest?to=${testEmail}`,
    { headers: { Authorization: `Bearer ${process.env.PLOP_API_KEY}` } }
  );
  const email = await response.json();

  // Extract verification link
  const linkMatch = email.htmlContent.match(/href="([^"]*verify[^"]*)"/);
  if (!linkMatch) throw new Error('No verification link found');

  // Navigate to verification link
  await page.goto(linkMatch[1]);

  // Verify account is now confirmed
  await page.waitForSelector('text=Email verified');

  // Take screenshot as evidence
  await page.screenshot({ path: 'verified.png' });

  await browser.close();
}

Tips

  • Use page.waitForNetworkIdle() after form submissions before fetching emails
  • Set a longer navigation timeout for pages that send emails
  • Use puppeteer-extra for additional features like stealth mode
  • Consider using jest-puppeteer for test framework integration

Related Integrations

Related Use Cases

Start testing with Puppeteer

Add email verification to your Puppeteer tests in minutes.