Skip to content

Playwright Integration

Use Bounce House with Playwright for end-to-end email flow testing.

Combine Bounce House receivers with Playwright to test full user flows that involve email — signup verification, password reset, invitation links, and more.

Setup

Install the Bounce House client alongside Playwright:

npm install -D @playwright/test

Set your API key as an environment variable:

export BOUNCEHOUSE_API_KEY=bh_your_key

Example: password reset flow

import { test, expect } from "@playwright/test";

const API = "https://api.bouncehouse.cloud";
const headers = {
  Authorization: `Bearer ${process.env.BOUNCEHOUSE_API_KEY}`,
  "Content-Type": "application/json",
};

test("password reset sends email and link works", async ({ page }) => {
  // Create a receiver
  const receiver = await fetch(`${API}/api/accounts/me/receivers`, {
    method: "POST",
    headers,
    body: JSON.stringify({ channel: "email", label: "pw-reset", ttl_seconds: 3600 }),
  }).then((r) => r.json());

  // Trigger password reset
  await page.goto("https://your-app.com/forgot-password");
  await page.fill('[name="email"]', receiver.address);
  await page.click('button[type="submit"]');

  // Wait for the reset email
  const message = await fetch(`${API}/api/accounts/me/receivers/${receiver.id}/wait?timeout=30`, {
    headers,
  }).then((r) => r.json());

  // Follow the reset link
  const resetLink = message.extracted.links[0];
  await page.goto(resetLink);

  // Complete the reset
  await page.fill('[name="password"]', "new-secure-password");
  await page.fill('[name="confirmPassword"]', "new-secure-password");
  await page.click('button[type="submit"]');

  await expect(page.locator("text=Password updated")).toBeVisible();

  // Clean up
  await fetch(`${API}/api/accounts/me/receivers/${receiver.id}`, {
    method: "DELETE",
    headers,
  });
});

Tips

  • Set ttl_seconds: 3600 (or shorter) for CI receivers — they auto-expire even if cleanup fails
  • Use label to identify receivers in the dashboard during debugging
  • The wait endpoint's timeout should exceed your app's email sending latency (30s is usually sufficient)

Was this page helpful?