From bcf0060ea2e748ca5f11199e481787eb367c8d10 Mon Sep 17 00:00:00 2001 From: George MacKerron Date: Wed, 18 Dec 2024 17:21:12 +0000 Subject: [PATCH] Added WebSocket shim for http tests --- tests/http.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/http.test.ts b/tests/http.test.ts index 4c07971..a79e87a 100644 --- a/tests/http.test.ts +++ b/tests/http.test.ts @@ -1,4 +1,4 @@ -import { expect, test, vi } from 'vitest'; +import { expect, test, vi, beforeAll } from 'vitest'; import { neon, neonConfig, Pool } from '../dist/npm'; import { sampleQueries } from './sampleQueries'; @@ -7,6 +7,13 @@ const sql = neon(DB_URL); const sqlFull = neon(DB_URL, { fullResults: true }); const pool = new Pool({ connectionString: DB_URL }); +beforeAll(async () => { + if (typeof WebSocket !== 'function') { + const { WebSocket } = await import('ws'); + neonConfig.webSocketConstructor = WebSocket; + } +}); + test( 'http query results match WebSocket query results', { timeout: 30000 },