Use Case
Selenium E2E Tests with MockHero Seeded Data
Pattern
Selenium doesn't care how the data got there — just make sure it's seeded before the browser hits the page. Use your CI's Before Suite step to call MockHero and populate your DB.
# .github/workflows/e2e.yml
- name: Seed test data
run: node scripts/seed.mjs
env:
MOCKHERO_API_KEY: ${{ secrets.MOCKHERO_API_KEY }}
DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
- name: Selenium tests
run: pytest tests/selenium
// scripts/seed.mjs
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());
// insert into test DB ...
Get Started
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