diff --git a/packages/pg-transaction/src/index.test.ts b/packages/pg-transaction/src/index.test.ts index 0537972b..7ea96f9a 100644 --- a/packages/pg-transaction/src/index.test.ts +++ b/packages/pg-transaction/src/index.test.ts @@ -147,4 +147,22 @@ describe('Transaction', () => { assert.equal(rows.length, 1, 'Row should be visible after transaction with return value') pool.end() }) + + it('does not throw an uncatchable error if pool cannot connect', async () => { + const pool = new Pool({ + connectionString: 'postgres://invalid:invalid@localhost:5432/invalid_db', + }) + + const promise = transaction(pool, async (client) => { + await client.query('SELECT 1') + }) + + try { + await assert.rejects(promise, { + name: 'error', + }) + } finally { + await pool.end() + } + }) })