pg-test is a focused command-line interface (CLI) utility designed for running tests directly from `.sql` files against a PostgreSQL database. As of version 1.0.7, it provides a straightforward mechanism for database-centric testing, executing each `.sql` file in a specified directory sequentially and stopping on the first failure. Its release cadence appears to be stable and utility-focused, without frequent major updates. Key differentiators include its simplicity, direct execution of SQL scripts, and reliance on a `DB` environment variable for database connection, making it suitable for CI environments like Travis-CI. Unlike typical JavaScript test runners, pg-test primarily operates on raw SQL files rather than integrating with JS/TS test frameworks.
npm install pg-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to run `pg-test` programmatically using `child_process` after setting the required `DB` environment variable, including creating a temporary SQL test file.
Ensure `export DB=postgres://user:password@host:port/database` (Linux/macOS) or `$env:DB='...'` (Windows PowerShell) is run before `pg-test`.
Interact with `pg-test` via `child_process.spawn` or `exec` methods in Node.js, or by running the `pg-test` command directly in your shell or CI/CD pipeline.
Consider structuring tests into smaller, independent files or using other test runners if comprehensive failure reporting is required.
Use pg-test for simple, direct SQL validation. For more complex testing scenarios involving application logic, integrate with a JS/TS test runner and a PostgreSQL client library (e.g., `node-postgres`).
Set the `DB` environment variable with a valid PostgreSQL connection string before running `pg-test`. Example: `export DB=postgres://user:pass@host:port/dbname`.
Verify that your PostgreSQL server is running, the specified host and port in the `DB` environment variable are correct, and no firewall is blocking the connection. Check PostgreSQL logs for details.
Review the SQL file where the error occurred. Correct the syntax. The error message usually provides clues about the line number or near where the error happened.
No dependency data recorded yet.