@xemahq/pg-test-harness
v0.3.1
Published
Test-only harness that boots a real PostgreSQL as a plain loopback process, migrates a throwaway schema, and exports DATABASE_URL — so database-backed conformance suites RUN instead of silently skipping. Also ships the repo's one ephemeral-port allocator
Readme
@xemahq/pg-test-harness
Real PostgreSQL conformance tests without external infrastructure
Overview
This package provisions an isolated PostgreSQL database for integration and conformance tests. It supports ephemeral embedded servers, existing database URLs, schema-scoped migrations, and declared extension requirements while keeping unavailable infrastructure explicit rather than silently skipping tests.
When to use it
- Use it when a test must exercise real PostgreSQL semantics or migrations.
- Use a unit-test fixture when the behavior does not depend on a database.
Installation
pnpm add -D @xemahq/pg-test-harnessUsage
import {
provisionTestDatabase,
releaseTestDatabase,
} from '@xemahq/pg-test-harness';
await provisionTestDatabase({ serviceName: 'my-service' });
try {
// Run database-backed tests using process.env.DATABASE_URL.
} finally {
await releaseTestDatabase();
}License
LicenseRef-Xema-BSL-1.1 © Xema — xema.dev
