Getting good data for end-to-end testing is a pain in the backend

Is your backend talking s%!t to your frontend?

Why generating production-like data for tests is worth fussing about

Writing test data is not particularly fun. In fact it can be quite tedious, diverting time and attention away from core development tasks - you know, the stuff you actually signed up for when you accepted the job. However, proper testing play a crucial role in ensuring that different components or layers of an application work seamlessly together.

The need for tests

Let’s look at the need for tests using back-end and front-end communication as an example to see where tests can be particularly useful.


Integration tests focus on validating the interactions and communication between various components of an application. These tests ensure that the different parts of the system (like frontend and backend) work together as expected.

API verification

For web applications, API testing is essential to verify that the backend API endpoints respond correctly to requests from the frontend. This ensures that data is exchanged appropriately between the frontend and backend components.

Recreating real world scenarios

End-to-end (E2E) tests mimic real user actions and help identify issues related to communication between the client and server.

Snappy is getting tested from end-to-end

Data flow testing

Tests can ensure that data flows correctly, for example, checking that data entered on the frontend is properly processed by the backend and that the responses are correctly displayed on the frontend.

Error handling

Testing error scenarios, such as server errors or network issues, helps ensure that the frontend gracefully handles unexpected situations and communicates errors to users appropriately. Nothing says “I don’t care” like a “404 Not Found”.

Cross-browser and cross-platform testing:

Ensuring that the application communicates correctly across different browsers and platforms is crucial. Cross-browser and cross-platform testing as part of E2E testing helps identify any compatibility issues that may affect communication.

By incorporating testing practices into the development process, teams can gain confidence in the correct communication between the different components of their applications. It helps identify and address issues early in the development lifecycle, leading to more robust and reliable software... hopefully. Here’s the caveat: You can have the best testing tools in the world, but when your data lacks integrity, your tests may pass, while your product fails. That is because writing the data for testing is often overlooked, rushed or completely forgotten about.

Getting data from you backend is not always easy

Generating data for tests can be painful

The repetitive and mundane nature of manually generating data for different test scenarios can be enormously boring. Let’s not even talk about the headache of maintaining the test data to align with changes in the database structure.

The human curse

Apart from being drab, the physical entry of data is error-prone. Why? because we’re not robots. Manually generated data often lacks in realism and fails to capture the complexities of real-world scenarios adequately. Despite our creative nature, we often make inaccurate or biased assumptions when it comes to the data we generate for our tests, which compromise the reliability of test results. Even telling Snappy, our cute mascot, they have to write a seed script is like putting the cat among the pigeons - it ain’t pretty. Yes, even cats do make mistakes (sometimes).

Let the robots do the work - AI to seed your database

Setting up a test environment poses some challenges for developers, impacting the efficiency and reliability of testing processes. The complexity arises from the need to populate the environment with accurate and relevant data that mirrors the production setting. Managing dependencies, ensuring consistency across environments, and adapting to dynamic changes add further complexity. Scalability issues may arise when dealing with large datasets or simulating production-like conditions.

Snaplet Seed

That is why we developed Snaplet Seed. Seed uses generative AI to give you production-like data to seed your testing database. This addresses the challenges faced by Snappy and many humans by automating data seeding and streamlining the environment setup process, ultimately contributing to a more robust and efficient testing infrastructure.

Automated values

Snaplet Seed automatically determines the values in your database so you don’t have to define each and every value unless you want to be specific. Our default data automatically adds necessary built-ins, like country lists, currency codes etc.

Automated relationships

Snaplet Seed automatically creates relational entities so you don’t have to keep track of IDs in one table when you’re defining values in another.

Type-safe by default

Snaplet Seed creates a TypeScript client based off your database structure. Values are safe, and soft documented. You have the full power of the typescript language and the rich Node.js infrastructure when seeding production-like data and defining data values.

Deterministic data

Snaplet Seed uses Copycat for its data generation functions, and all data generation is fully deterministic. That means if you use the same inputs, you'll always get the same data outputs. That makes Seed great for creating consistent testing environments.

If you hate writing scripts to setup your tests, then Seed is the answer. Contact us for a demo and we will take you through the process step-by-step or check out our documentation and jump in to it straight away.

Other articles you may be interested in:

Almarie Stander
May 3, 2024