deadhead-space-freight-tycoon/apps/server/test/helpers.ts

19 lines
687 B
TypeScript

import { loadConfig, type ServerConfig } from "../src/config";
/** Config for tests: silent logs, an ephemeral port, and the test database. */
export function testConfig(overrides: Record<string, string> = {}): ServerConfig {
const testDatabaseUrl =
process.env.TEST_DATABASE_URL ?? "postgres://deadhead:deadhead@localhost:5432/deadhead_test";
return loadConfig({
NODE_ENV: "test",
PORT: "0",
LOG_LEVEL: "silent",
DATABASE_URL: testDatabaseUrl,
TEST_DATABASE_URL: testDatabaseUrl,
BETTER_AUTH_SECRET: "test-secret-that-is-at-least-32-characters-long",
BETTER_AUTH_URL: "http://localhost:3000",
WORKERS_ENABLED: "false",
...overrides,
});
}