test-data-bot is a JavaScript library designed for easily generating dynamic test data for unit and integration tests. It operates agnostic of specific test runners or frameworks, providing a fluent API for defining data builders. As of version 0.8.0, it offers features like static values, unique sequences, data generation using `faker.js` (internally), per-build instance generation, incrementing IDs, random selection from a list, and array generation. The package emphasizes simplicity and flexibility, allowing for easy overrides and custom mapping functions to transform generated plain JavaScript objects into class instances or specific formats. Its release cadence appears to follow semantic versioning, with `0.x` indicating pre-1.0 development. Key differentiators include its simple, builder-pattern API and deep integration with `faker.js` without exposing it as a direct peer dependency.
npm install test-data-botVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a basic user builder, generating multiple unique users, overriding specific fields, and extending an existing builder for an admin user.
Understand the scope: `sequence` is per-field, `incrementingId` is global. Use `incrementingId` when truly unique IDs are needed across an entire test run, or manage custom sequencing manually for specific scenarios.
Rely on `test-data-bot`'s public API and avoid direct `faker.js` imports if strict control over `faker.js` versions or features is required, consider using `faker.js` directly or wrapping its functions within `fake()`.
Always call the builder when passing it to `arrayOf` if you intend to generate objects: `arrayOf(() => myBuilder(), 3)`. The function wrapper ensures a new instance is created for each array element.
For complex nested object overrides, consider using nested builders or applying a `map` function to post-process the generated data. Alternatively, ensure nested objects are themselves created by sub-builders that can be individually overridden.
Ensure correct import syntax: `const { build, fake } = require('test-data-bot');` for CommonJS or `import { build, fake } from 'test-data-bot';` for ESM.All `faker.js` methods must be accessed via the `f` argument provided to the callback inside `fake()`: `fake(f => f.name.firstName())`.
Verify that your `fake()` callback receives the `faker` instance as an argument (`fake(f => ...)`) and that the `faker.js` method you are calling (e.g., `f.name.findName()`) exists in the `faker.js` API.
No dependency data recorded yet.