Registry / testing / db-seeder-postgres

db-seeder-postgres

JSON →
library0.2.0jsnpmunverified

A lightweight PostgreSQL seeding server designed for E2E tests, version 0.2.0. It runs as an HTTP server that auto-generates REST endpoints for each database table, allowing tests to seed or truncate data via POST requests. Integrates easily with Cypress and Playwright. Requires an existing database schema. Can be deployed via Docker compose or npm. No CLI or programmatic API beyond the HTTP server.

npm install db-seeder-postgres
INSTALL
IMPORT
SIG · DB-SEEDER-POSTGRES
D
db-seeder-postgres
testingjavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

db-seeder-postgres (server process)
✓ script: 'db-seeder-postgres run' in package.json, then run with npm
✗ import { something } from 'db-seeder-postgres'
The package provides a CLI binary, not a JavaScript module. Use via npm script or npx.
HTTP endpoint (seed)
✓ POST http://localhost:3000/seed/{tableName} with JSON body
✗ GET or PUT request
Only POST method is supported for seeding.
HTTP endpoint (truncate)
✓ POST http://localhost:3000/truncate/{tableName} or /truncate
✗ GET /truncate or DELETE request
Truncation is also via POST, with optional query params.

Shows seeding and truncating a PostgreSQL table via HTTP POST using Cypress or Playwright.

// Ensure PostgreSQL is running and tables exist // Start the seeder server via Docker compose or npm script // Then in your test: const baseUrl = 'http://localhost:3000'; // Seed table 'users' with two rows const users = [ { id: 1, name: 'John Doe' }, { id: 2, name: 'Jane Doe' } ]; // Using Cypress cy.request('POST', `${baseUrl}/seed/users`, users); // Using Playwright await request.post(`${baseUrl}/seed/users`, { data: users }); // Truncate table 'users' cy.request('POST', `${baseUrl}/truncate/users`); // Truncate all tables await request.post(`${baseUrl}/truncate`);
Debug
Known issues
gotchaTable must exist before seeding; the server does not create tables.
fix
Initialize database schema via SQL migration or entrypoint script before starting the seeder.
affects: >=0.1.0
gotchaOnly POST method is supported for seeding and truncation – GET, PUT, DELETE are not implemented.
fix
Use POST requests with the appropriate JSON body.
affects: >=0.1.0
gotchaEnvironment variables POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB must be set, or the server will fail to connect.
fix
Ensure all four variables are available to the server process.
affects: >=0.1.0
gotchaTruncate with CASCADE by default; use ?noCascade=true to avoid cascading.
fix
Pass query parameter ?noCascade=true if you do not want cascading truncation.
affects: >=0.2.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:3000
Database seeder server not running or wrong port.
fix
Start the server with `npm run db-seeder` or via Docker compose, ensure port 3000 is exposed and accessible.
error: relation "users" does not exist
Table 'users' does not exist in the target database.
fix
Create the table via SQL before starting the seeder, e.g., by adding an init SQL script to Docker entrypoint.
error: password authentication failed for user "postgres"
POSTGRES_PASSWORD environment variable is missing or incorrect.
fix
Set POSTGRES_PASSWORD in .env file or environment of the seeder container/process.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
db-seeder-postgres — npm install db-seeder-postgres · libregistry