@@ -7,8 +7,22 @@ const SUPABASE_URL = 'http://127.0.0.1:54321'
7
7
const ANON_KEY =
8
8
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
9
9
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
+
10
21
const supabase = createClient ( SUPABASE_URL , ANON_KEY , {
11
- realtime : { heartbeatIntervalMs : 500 } ,
22
+ realtime : {
23
+ heartbeatIntervalMs : 500 ,
24
+ ...( wsTransport && { transport : wsTransport } ) ,
25
+ } ,
12
26
} )
13
27
14
28
describe ( 'Supabase Integration Tests' , ( ) => {
@@ -315,7 +329,10 @@ describe('Storage API', () => {
315
329
// use service_role key for bypass RLS
316
330
const SERVICE_ROLE_KEY = process . env . SUPABASE_SERVICE_ROLE_KEY || 'use-service-role-key'
317
331
const supabaseWithServiceRole = createClient ( SUPABASE_URL , SERVICE_ROLE_KEY , {
318
- realtime : { heartbeatIntervalMs : 500 } ,
332
+ realtime : {
333
+ heartbeatIntervalMs : 500 ,
334
+ ...( wsTransport && { transport : wsTransport } ) ,
335
+ } ,
319
336
} )
320
337
321
338
test ( 'upload and list file in bucket' , async ( ) => {
0 commit comments