Guides & Tutorials
E2E Auth Testing with Temp Mail in CI/CD
How to automate email verification and magic link testing in GitHub Actions using the Temp Mail API.
E2E Auth Testing with Temp Mail in CI/CD
Testing user signups and magic links in automated CI/CD pipelines often causes headaches with rate limits and spam filters. The 1st Services Temp Mail API solves this by providing isolated, programmatic mailboxes.
Complete GitHub Actions Workflow
.github/workflows/e2e.yml
name: E2E Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run E2E Auth Tests
env:
FIRST_API_KEY: ${{ secrets.FIRST_API_KEY }}
BASE_URL: "https://staging.myapp.com"
run: npm run test:e2e
Test Implementation (TypeScript + Playwright)
tests/auth-flow.spec.ts
import { test, expect } from '@playwright/test'
import { FirstClient } from '@1st-services/sdk'
const first = new FirstClient({
apiKey: process.env.FIRST_API_KEY!,
})
test('Complete Signup & Email Verification Flow', async ({ page }) => {
// 1. Generate unique temporary inbox for this specific test run
const inbox = await first.tempMail.createInbox({
prefix: `ci-test-${Date.now()}`,
ttlMinutes: 10,
})
// 2. Perform signup on your application
await page.goto(`${process.env.BASE_URL}/register`)
await page.fill('input[name="full_name"]', 'Automated QA Bot')
await page.fill('input[name="email"]', inbox.address)
await page.fill('input[name="password"]', 'SuperSecretPass123!')
await page.click('button[type="submit"]')
// 3. Poll 1st Services API for incoming email (auto-times out if not received)
const email = await first.tempMail.waitForMessage(inbox.id, {
timeoutMs: 15000,
pollIntervalMs: 1000,
})
expect(email.subject).toContain('Verify your email address')
// 4. Extract verification link or OTP code
const verificationLink = email.parsedLinks[0]
expect(verificationLink).toBeDefined()
// 5. Navigate to verification link
await page.goto(verificationLink)
await expect(page.locator('h1')).toContainText('Email Verified Successfully')
})
