Test Automation

Integrate SigninID into your E2E tests to automate email verification flows. Use waitForNew() to wait for verification emails and extract OTP codes automatically.

Complete Examples

Each example shows a full signup flow: fill form, wait for email, enter OTP, verify success.

import { test, expect } from '@playwright/test';
import { SigninID } from 'signinid';

test('signup with email verification', async ({ page }) => {
  const client = new SigninID();
  const testEmail = `test-${Date.now()}@your-server.signinid.com`;

  // Fill signup form
  await page.goto('/signup');
  await page.fill('[name="email"]', testEmail);
  await page.fill('[name="password"]', 'SecurePass123!');
  await page.click('button[type="submit"]');

  // Wait for verification email (polls until arrival, 30s timeout)
  const email = await client.inbox.waitForNew({ to: testEmail });
  expect(email).not.toBeNull();

  // Enter OTP
  await page.fill('[name="otp"]', email!.detected_otp!);
  await page.click('button[type="submit"]');

  await expect(page).toHaveURL('/dashboard');
});

Tips

  • 1.Use unique email addresses: Use test-${Date.now()}@... pattern to isolate parallel test runs.
  • 2.Use waitForNew(): Polls until email arrives - no arbitrary waitForTimeout() needed.
  • 3.Adjust timeout if needed: Default is 30 seconds. Use { timeout: 60000 } for slower environments.
  • 4.Use environment variables: Set SIGNINID_SECRET_KEY and just call new SigninID().