Use Case

Playwright E2E Tests with Realistic Data from MockHero

Global Setup

// playwright.config.ts
export default defineConfig({
  globalSetup: "./tests/global-setup.ts",
  // ...
});
// tests/global-setup.ts
import { createClient } from "@supabase/supabase-js";

export default async () => {
  const supabase = createClient(
    process.env.SUPABASE_URL!,
    process.env.SUPABASE_SERVICE_ROLE_KEY!
  );

  const data = await fetch("https://api.mockhero.dev/api/v1/generate", {
    method: "POST",
    headers: { "x-api-key": process.env.MOCKHERO_API_KEY!, "Content-Type": "application/json" },
    body: JSON.stringify({
      seed: 1,
      tables: [
        { name: "users", count: 10, fields: [
          { name: "id", type: "uuid" },
          { name: "email", type: "email" }
        ]}
      ]
    })
  }).then(r => r.json());

  await supabase.from("users").upsert(data.users);
};

Now every Playwright test starts against a realistic 10-user dataset.

Get Started

Free API key.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles