ProductHow it worksPricingBlogDocsLoginFind Your First Bug
Placeholder image
TestingAIData Seeding

AI Data Seeding for End-to-End Testing

Eugenio Scafati
Eugenio ScafatiCEO at Autonoma
Tom Piaggio
Tom PiaggioCTO at Autonoma

When building and testing applications, using real data can sometimes be impractical or risky, especially if the data includes sensitive information. Instead, developers often rely on dummy and anonymized data to simulate real-world data while ensuring privacy and compliance with data protection regulations. This blog post explores how to automatically generate such data based on your Object-Relational Mapping (ORM) schema using popular libraries in JavaScript and Python. We'll also touch on how generative AI can further streamline this process.

1. Understanding the Importance of Dummy Data

Dummy data is crucial for testing because it allows developers to:

  • Simulate how applications will perform with real data.
  • Ensure privacy by not using actual customer data.
  • Test the handling of various data types and formats.
  • Validate application behavior under different data loads.

2. Generating Data with ORM Schemas

Most modern ORMs support features or extensions that can generate data directly from the database schema. This means you can automatically create data that adheres to the constraints and relationships defined in your ORM models.

For JavaScript: Using faker.js

Faker.js is a popular library in the JavaScript ecosystem used to generate massive amounts of fake (but realistic) data for various purposes, such as testing and filling databases. Here’s a simple way to integrate faker.js with a Sequelize ORM model:

const { faker } = require('@faker-js/faker');
const { User } = require('./models');
async function generateUsers(count = 10) {
    for (let i = 0; i < count; i++) {
        await User.create({
            username: faker.internet.userName(),
            email: faker.internet.email(),
            bio: faker.lorem.sentence(),
        });
    }
}

In this example, faker.js generates usernames, emails, and bios, which are then inserted into the database using Sequelize models.

For Python: Using Faker

Python’s equivalent to faker.js is Faker. It's a powerful library capable of producing a similar range of fake data. Integrating Faker with Django ORM would look like this:

from faker import Faker
from myapp.models import User
fake = Faker()
def generate_users(count=10):
    for _ in range(count):
        User.objects.create(
        username=fake.user_name(),
        email=fake.email(),
        bio=fake.sentence(),
    )

Here, Faker is used to populate a Django model with fake usernames, emails, and bios.

Once your test data is seeded, Autonoma handles the E2E test execution — AI agents read your codebase and run tests against your seeded environment on every PR.

3. Advanced Use: Custom Providers

Both faker.js and Faker allow the creation of custom providers if the data you need is not covered by the default providers. For instance, if you need to generate user roles that conform to specific rules in your application, you can define a custom provider to ensure the roles are valid according to your business logic.

4. Leveraging Generative AI for Synthetic Data

As AI technology advances, so does the ability to generate sophisticated and context-aware synthetic data. Generative AI models can be trained on a subset of your real data (ensuring no sensitive data is included) to produce high-quality synthetic data that mimics real-world scenarios more closely than what simple dummy data generators can provide. This can be particularly useful for complex data interactions and behaviors that are hard to simulate with traditional methods.

Example with OpenAI's GPT-4

You can use GPT-4 to generate text-based data or even code snippets that can be used as part of your testing framework. For example, GPT-4 can generate realistic chat logs, customer support inquiries, or product descriptions that can be used to test natural language processing systems.

Conclusion

Using libraries like faker.js and Faker to generate dummy data based on your ORM schema is a proven method to enhance application testing by providing realistic data inputs. As we integrate more advanced tools, such as generative AI models like GPT-4, developers can create even more complex and varied datasets that are tailored to the nuanced needs of modern applications. This combination of traditional methods and cutting-edge AI opens up new possibilities for rigorous and effective testing.

Related articles

Ghost Inspector alternative concept: Quara the frog beside a cracked recorded-test snapshot next to a regenerating test path

Ghost Inspector Alternative: Recorder, Framework, or AI?

Looking for a Ghost Inspector alternative? Compare record-and-playback SaaS, code frameworks, and AI-agent-generated testing by approach, not just by tool.

Diagram showing AI-generated auth code without a baseline: an agent writes login code on one side, while expected auth behavior (valid login, rejected password, protected route redirect) must be defined explicitly on the other

How to Test the Auth Code an AI Agent Wrote

When an AI agent writes your authentication, there is no baseline for correct behavior. Here is how to test AI-generated code for the auth bugs that compile, pass review, and lock users out.

Split diagram showing code that compiles cleanly on the left and a broken login flow at runtime on the right, illustrating what AI code review cannot see

Why AI Code Review Misses Auth Bugs

AI code review catches structure and style. It cannot catch a dropped auth wrapper or broken login flow. Here is what code review misses and why E2E testing fills the gap.

Quara reviewing a dark isometric authentication priority board with login, SSO, payment, recovery, MFA, session, and role-change props arranged by coverage priority

Authentication Testing Strategy for Teams With No QA

Authentication testing strategy for lean teams: get E2E coverage of login, SSO, and payments without a QA team, then pick scripts or a self-maintaining agent.