Test Data for CI/CD Pipelines with MockHero
The Problem
CI/CD pipelines need consistent test data, but most approaches fail. Shared staging databases get corrupted by parallel test runs. Fixture files go stale. Random Faker data produces flaky tests because assertions depend on values that change every run.
You need data that is realistic enough to test real behavior, but deterministic enough that assertions are stable across every build.
The Solution: MockHero API
MockHero's seed parameter generates identical data every time. Pass the same seed, get the same records. Your tests can assert on specific values and pass reliably in CI. Change the seed to generate a completely different dataset.
Quick Setup
curl -X POST https://api.mockhero.dev/api/v1/generate \
-H "x-api-key: mh_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"tables": [
{
"name": "users",
"count": 5,
"fields": [
{ "name": "id", "type": "uuid" },
{ "name": "email", "type": "email" },
{ "name": "name", "type": "full_name" }
]
}
],
"format": "json",
"seed": 42
}'
Step-by-Step Guide
1. Choose a fixed seed
Pick any integer as your seed value. The same seed always returns the same data.
2. Get your MockHero API key
Sign up at mockhero.dev/sign-up. Store the key as a CI secret.
3. Create a setup script
Write a test/setup.mjs that calls MockHero with a fixed seed and inserts the data into your test database before tests run.
4. Add to your CI config
# .github/workflows/test.yml
- name: Seed test database
env:
MOCKHERO_API_KEY: ${{ secrets.MOCKHERO_API_KEY }}
run: node test/setup.mjs
5. Write stable assertions
Since the data is deterministic, you can assert on exact values in your tests. The first user will always have the same name and email.
Complete Example
The setup script and CI config above form the complete workflow. Every build gets identical data, making tests reliable and debuggable.
Why MockHero vs Faker / Fixtures
- Deterministic — same
seed= same data, every time. No flaky tests. - No fixture files — generate fresh data that matches your current schema automatically.
- Parallel-safe — each test run gets its own isolated dataset.
Get Started
Free tier, no credit card. Sign up at mockhero.dev and make your CI tests deterministic today.
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