Skip to content

Commit 59b4084

Browse files
georgiy.rusanovmandarini
authored andcommitted
added test for issue 1470
1 parent 7876a24 commit 59b4084

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
- name: Run Unit Tests + Coverage
8888
run: npm run test:coverage
8989

90+
- name: Run isows Compatibility Test
91+
run: npm run test:isows-compatibility
92+
9093
- name: Upload coverage results to Coveralls
9194
uses: coverallsapp/github-action@v2
9295
with:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
3737
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
3838
"test:edge-functions": "deno test --allow-all --no-check test/deno/edge-functions-integration.test.ts",
39+
"test:isows-compatibility": "jest --runInBand --detectOpenHandles test/isowsAbsentsCompatibility.test.ts",
3940
"test:watch": "jest --watch --verbose false --silent false",
4041
"test:node:playwright": "cd test/integration/node-browser && npm install && cp ../../../dist/umd/supabase.js . && npm run test",
4142
"test:bun": "cd test/integration/bun && bun install && bun test",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as fs from 'fs'
2+
import * as path from 'path'
3+
4+
// Simulates isows removal (like in server environments)
5+
function simulateIsowsRemoval(): { backupPath: string; originalPath: string } {
6+
const originalPath = path.join(__dirname, '..', 'node_modules', 'isows')
7+
const backupPath = path.join(__dirname, '..', 'node_modules', 'isows_backup')
8+
9+
try {
10+
if (fs.existsSync(originalPath)) {
11+
fs.renameSync(originalPath, backupPath)
12+
console.log('📦 isows temporarily removed (server environment simulation)')
13+
}
14+
} catch (error) {
15+
console.log('⚠️ Failed to remove isows:', (error as Error).message)
16+
}
17+
18+
return { backupPath, originalPath }
19+
}
20+
21+
// Restores isows
22+
function restoreIsows(backupPath: string, originalPath: string): void {
23+
try {
24+
if (fs.existsSync(backupPath)) {
25+
fs.renameSync(backupPath, originalPath)
26+
console.log('📦 isows restored')
27+
}
28+
} catch (error) {
29+
console.log('⚠️ Failed to restore isows:', (error as Error).message)
30+
}
31+
}
32+
33+
function testIsowsAvailability(): boolean {
34+
try {
35+
require('isows')
36+
return true
37+
} catch {
38+
console.log('isows is not available')
39+
return false
40+
}
41+
}
42+
43+
function testRealtimeClientCreation(): boolean {
44+
try {
45+
const { RealtimeClient } = require('@supabase/realtime-js')
46+
new RealtimeClient('ws://localhost:54321/realtime/v1')
47+
return true
48+
} catch {
49+
console.log('realtime client is not available')
50+
return false
51+
}
52+
}
53+
54+
/**
55+
* Jest test for isows compatibility
56+
*/
57+
58+
describe('isows compatibility', () => {
59+
let backupPath: string
60+
let originalPath: string
61+
62+
beforeEach(() => {
63+
;({ backupPath, originalPath } = simulateIsowsRemoval())
64+
console.log('backupPath', backupPath)
65+
console.log('originalPath', originalPath)
66+
})
67+
68+
afterEach(() => {
69+
restoreIsows(backupPath, originalPath)
70+
})
71+
72+
it('should work without isows dependency', () => {
73+
const isowsAvailable = testIsowsAvailability()
74+
const isRealtimeClientWorks = testRealtimeClientCreation()
75+
76+
expect(isowsAvailable).toBe(false)
77+
expect(isRealtimeClientWorks).toBe(true) // should be true because realtime-js doesn't use isows
78+
})
79+
})

0 commit comments

Comments
 (0)