Cypress Test Data Generator is a Cypress plugin (currently at version 2.0.2) designed to simplify the creation of realistic, reproducible test data for end-to-end tests. It leverages the popular Faker.js library to provide over 40 distinct data generators for common entities like users, products, orders, and social profiles, along with extensive support for internationalization across 50+ locales. The plugin integrates seamlessly with Cypress via `cy.task`, allowing data generation directly within test specs or before hooks, executed in the Node.js environment. Its key differentiators include seed support for consistent data across test runs, fully typed APIs for better developer experience, and a zero-configuration approach with sensible defaults, significantly reducing the boilerplate associated with manual test data creation. The project appears actively maintained with a stable release cadence. It aims to eliminate the tedious and error-prone process of manually crafting test data, providing a robust and flexible alternative for modern Cypress workflows.
npm install cypress-test-data-generatorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `cypress-test-data-generator` into `cypress.config.js` and use `cy.task` in a test to generate diverse, reproducible data like users, products, and reviews, including locale and seeding options.
Ensure `return config;` is the last statement within your `setupNodeEvents` function: `setupNodeEvents(on, config) { on('task', dataGenerator(on, config)); return config; }`Always invoke data generators through `cy.task('generatorName', options)` within your Cypress tests.For reproducible test scenarios where data consistency is crucial, always specify a `seed` value in your generator options: `cy.task('generateUser', { seed: 12345 })`.Stick to `const dataGenerator = require('cypress-test-data-generator');` for `cypress.config.js` unless explicitly configured for ESM and the plugin is verified to support it seamlessly.Verify that `on('task', dataGenerator(on, config));` is present and that `return config;` is the final statement within the `e2e.setupNodeEvents` function in your `cypress.config.js`.Ensure the import is `const dataGenerator = require('cypress-test-data-generator');` and it's called as `dataGenerator(on, config)` when registering tasks: `on('task', dataGenerator(on, config));`.The `faker` library is an internal dependency used by the plugin in the Node.js environment. Access generated data exclusively through the `cy.task()` interface, for example, `cy.task('generateUser')`, rather than attempting to call `faker` directly.