devseed
v0.1.0
Published
A smart test data generation toolkit for Node.js with relational data support.
Maintainers
Readme
DevSeed
A Smart Test Data Generation Toolkit for Node.js
DevSeed is a JavaScript library that helps developers generate realistic test data for applications, export it into different formats, and insert generated records into PostgreSQL.
Features
- Realistic test data generation using Faker.js
- Custom schemas and field validation
- Reproducible data generation using seeds
- Unique and optional fields
- Nested objects and arrays
- One-to-one, one-to-many and many-to-many relationships
- JSON, CSV and SQL export
- PostgreSQL integration
- Command-line interface (CLI)
- Automated tests using Vitest
Tech Stack
- JavaScript (ES Modules)
- Node.js
- Faker.js
- Commander.js
- PostgreSQL
- CSV Stringify
- Vitest
- tsup
Project Structure
devseed/
├── src/
│ ├── core/
│ ├── database/
│ ├── exporters/
│ ├── generators/
│ ├── relationships/
│ └── cli/
├── tests/
├── examples/
├── dist/
├── package.json
└── README.mdInstallation
npm install devseedFor PostgreSQL support:
npm install pgUsage
Generate test data
import { createGenerator } from "devseed";
const generator = createGenerator({
seed: 12345
});
const students = generator.generate({
count: 5,
schema: {
id: "uuid",
name: "name",
email: {
type: "email",
unique: true
},
age: {
type: "number",
min: 18,
max: 25
},
city: "city"
}
});
console.log(students);Export data
import {
exportToJSON,
exportToCSV,
exportToSQL
} from "devseed";
const json = exportToJSON(students);
const csv = exportToCSV(students);
const sql = exportToSQL(students, {
tableName: "students"
});Use the CLI
devseed generate --schema examples/student-schema.json --count 5 --format jsonSupported formats:
- json
- csv
- sql
PostgreSQL integration
DevSeed provides a PostgreSQL adapter for inserting generated records into a database.
import { createPostgresAdapter } from "devseed";
const db = await createPostgresAdapter({
host: "localhost",
user: "postgres",
database: "devseed"
});
try {
await db.testConnection();
await db.insert("students", students);
} finally {
await db.close();
}Running Tests
npm testBuilding the Package
npm run buildAuthor
Vanshika
License
MIT
