Skip to content

Commit 5ac9926

Browse files
committed
fix: update test to provide ws
1 parent 2da3b97 commit 5ac9926

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/integration.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,22 @@ const SUPABASE_URL = 'http://127.0.0.1:54321'
77
const ANON_KEY =
88
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
99

10+
// For Node.js < 22, we need to provide a WebSocket implementation
11+
// Node.js 22+ has native WebSocket support
12+
let wsTransport: any = undefined
13+
if (typeof WebSocket === 'undefined' && typeof process !== 'undefined' && process.versions?.node) {
14+
try {
15+
wsTransport = require('ws')
16+
} catch (error) {
17+
console.warn('WebSocket not available, Realtime features may not work')
18+
}
19+
}
20+
1021
const supabase = createClient(SUPABASE_URL, ANON_KEY, {
11-
realtime: { heartbeatIntervalMs: 500 },
22+
realtime: {
23+
heartbeatIntervalMs: 500,
24+
...(wsTransport && { transport: wsTransport }),
25+
},
1226
})
1327

1428
describe('Supabase Integration Tests', () => {
@@ -315,7 +329,10 @@ describe('Storage API', () => {
315329
// use service_role key for bypass RLS
316330
const SERVICE_ROLE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || 'use-service-role-key'
317331
const supabaseWithServiceRole = createClient(SUPABASE_URL, SERVICE_ROLE_KEY, {
318-
realtime: { heartbeatIntervalMs: 500 },
332+
realtime: {
333+
heartbeatIntervalMs: 500,
334+
...(wsTransport && { transport: wsTransport }),
335+
},
319336
})
320337

321338
test('upload and list file in bucket', async () => {

0 commit comments

Comments
 (0)