Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3083f97
fix: bump realtime-js
grdsdev Jun 3, 2025
ed21283
fix: bump up realtime (#1443)
filipecabaco Jun 4, 2025
b1f81e3
Merge remote-tracking branch 'origin/master' into next
grdsdev Jun 6, 2025
6daee83
Merge remote-tracking branch 'origin/master' into next
grdsdev Jun 6, 2025
5552b4a
fix: bump realtime-js (#1453)
grdsdev Jun 6, 2025
852e6b3
bump realtime-js
grdsdev Jun 9, 2025
6386767
fix: bump realtime-js (#1456)
grdsdev Jun 9, 2025
0822961
fix: bump realtime-js
grdsdev Jun 10, 2025
7188f18
fix: bump realtime-js to 2.11.11-next.5
grdsdev Jun 12, 2025
2d2383d
test(deno): add integration tests for deno
grdsdev Jun 6, 2025
e48fc3d
rollback running integration test twice
grdsdev Jun 6, 2025
808215f
downgrade deno
grdsdev Jun 9, 2025
c4a2e47
run only for deno 2
grdsdev Jun 9, 2025
f74e9dd
add example deno
grdsdev Jun 9, 2025
17c3317
move to test folder
grdsdev Jun 9, 2025
05ccbb4
use old deno lock
grdsdev Jun 9, 2025
689671c
clean up
grdsdev Jun 9, 2025
4c61652
ignore memory leak errors on test
grdsdev Jun 9, 2025
0aa8934
set broken supabase version for testing
grdsdev Jun 9, 2025
8c626fc
use latest supabase-js version
grdsdev Jun 9, 2025
2132bef
regenerate deno.lock
grdsdev Jun 9, 2025
95eeb7e
deno test using npm
grdsdev Jun 12, 2025
e574415
use clean-install
grdsdev Jun 12, 2025
096ee3d
remove lock file
grdsdev Jun 13, 2025
f2b217d
run build
grdsdev Jun 13, 2025
eeb1c13
run tests only for deno 2
grdsdev Jun 13, 2025
a3fedc3
run deno test twice
grdsdev Jun 13, 2025
bcc8ab1
run deno test twice
grdsdev Jun 13, 2025
6e8db7e
chore: add imports section to `deno.json`
nyannyacha Jun 16, 2025
66135de
chore: update `ci.yml`
nyannyacha Jun 16, 2025
1653ae6
chore: create script for generating deno.json file
grdsdev Jun 16, 2025
8b02508
remove deno.json
grdsdev Jun 16, 2025
98b7bec
run browser integration after node
grdsdev Jun 16, 2025
b0ec523
run setup-deps before running tests
grdsdev Jun 16, 2025
f87b7a6
revert realtime-js version
grdsdev Jun 16, 2025
992ac91
remove .tools-version
grdsdev Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
matrix:
os: [ubuntu-latest]
node: ['20']
deno: ['2.x']
deno: ['1.x', '2.x']

runs-on: ${{ matrix.os }}

Expand All @@ -78,12 +78,22 @@ jobs:
run: |
supabase start

- name: Run tests
- name: Build
run: |
npm clean-install
npm run build

- name: Run tests
if: ${{ matrix.deno == '2.x' }}
run: |
npm run test:integration || npm run test:integration
npm run test:integration:browser

- name: Run Deno tests
run: |
cd test/deno
npm test || npm test

- name: Stop Supabase
run: |
supabase stop
89 changes: 0 additions & 89 deletions deno.lock

This file was deleted.

3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"test": "run-s test:types test:run",
"test:all": "run-s test:types test:run test:integration test:integration:browser",
"test:run": "jest --runInBand --detectOpenHandles",
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*\"",
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*|test/deno.*\"",
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
"test:db": "cd infra/db && docker-compose down && docker-compose up -d && sleep 5",
Expand All @@ -54,7 +54,7 @@
"@sebbo2002/semantic-release-jsr": "^1.0.0",
"@solana/wallet-standard-features": "^1.3.0",
"@types/jest": "^29.2.5",
"husky": "^4.3.0",
"husky": "^4.3.8",
"jest": "^29.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion supabase/.temp/cli-latest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.22.12
v2.24.3
1 change: 1 addition & 0 deletions test/deno/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deno.json
147 changes: 147 additions & 0 deletions test/deno/integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { assertEquals, assertExists } from 'https://deno.land/[email protected]/assert/mod.ts'
import { createClient, SupabaseClient } from '../../dist/module/index.js'
import type { RealtimeChannel } from '../../dist/module/index.js'

// These tests assume that a local Supabase server is already running
// Start a local Supabase instance with 'supabase start' before running these tests

// TODO: Remove sanitizeOps and sanitizeResources once the issue is fixed
Deno.test(
'Supabase Integration Tests',
{ sanitizeOps: false, sanitizeResources: false },
async (t) => {
// Default local dev credentials from Supabase CLI
const SUPABASE_URL = 'http://127.0.0.1:54321'
const ANON_KEY =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'

const supabase = createClient(SUPABASE_URL, ANON_KEY, {
realtime: { heartbeatIntervalMs: 500 },
})

// Cleanup function to be called after all tests
const cleanup = async () => {
await supabase.auth.signOut()
await supabase.auth.stopAutoRefresh()
await supabase.removeAllChannels()
// Give some time for cleanup to complete
await new Promise((resolve) => setTimeout(resolve, 1000))
}

try {
await t.step('should connect to Supabase instance', () => {
assertExists(supabase)
assertEquals(supabase instanceof SupabaseClient, true)
})

await t.step('PostgREST - should query data from public schema', async () => {
const { data, error } = await supabase.from('todos').select('*').limit(5)

// The default schema includes a 'todos' table, but it might be empty
assertEquals(error, null)
assertEquals(Array.isArray(data), true)
})

await t.step('PostgREST - should create and delete a todo', async () => {
// Create a new todo
const { data: createdTodo, error: createError } = await supabase
.from('todos')
.insert({ task: 'Integration Test Todo', is_complete: false })
.select()
.single()

assertEquals(createError, null)
assertExists(createdTodo)
assertEquals(createdTodo!.task, 'Integration Test Todo')
assertEquals(createdTodo!.is_complete, false)

// Delete the created todo
const { error: deleteError } = await supabase
.from('todos')
.delete()
.eq('id', createdTodo!.id)

assertEquals(deleteError, null)

// Verify the todo was deleted
const { data: fetchedTodo, error: fetchError } = await supabase
.from('todos')
.select('*')
.eq('id', createdTodo!.id)
.single()

assertExists(fetchError)
assertEquals(fetchedTodo, null)
})

await t.step('Authentication - should sign up a user', async () => {
const email = `test-${Date.now()}@example.com`
const password = 'password123'

const { data, error } = await supabase.auth.signUp({
email,
password,
})

assertEquals(error, null)
assertExists(data.user)
assertEquals(data.user!.email, email)
})

await t.step('Realtime - is able to connect and broadcast', async () => {
const channelName = `channel-${crypto.randomUUID()}`
let channel: RealtimeChannel
const email = `test-${Date.now()}@example.com`
const password = 'password123'

// Sign up and create channel
await supabase.auth.signUp({ email, password })
const config = { broadcast: { self: true }, private: true }
channel = supabase.channel(channelName, { config })
await supabase.realtime.setAuth()

const testMessage = { message: 'test' }
let receivedMessage: any
let subscribed = false
let attempts = 0

channel
.on('broadcast', { event: '*' }, (payload: unknown) => (receivedMessage = payload))
.subscribe((status: string) => {
if (status == 'SUBSCRIBED') subscribed = true
})

// Wait for subscription
while (!subscribed) {
if (attempts > 50) throw new Error('Timeout waiting for subscription')
await new Promise((resolve) => setTimeout(resolve, 100))
attempts++
}

attempts = 0

channel.send({
type: 'broadcast',
event: 'test-event',
payload: testMessage,
})

// Wait on message
while (!receivedMessage) {
if (attempts > 50) throw new Error('Timeout waiting for message')
await new Promise((resolve) => setTimeout(resolve, 100))
attempts++
}

assertExists(receivedMessage)
assertEquals(supabase.realtime.getChannels().length, 1)

// Cleanup channel
await channel.unsubscribe()
})
} finally {
// Ensure cleanup runs even if tests fail
await cleanup()
}
}
)
52 changes: 52 additions & 0 deletions test/deno/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions test/deno/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "test-deno",
"private": true,
"scripts": {
"test": "npm run setup-deps && deno test --allow-all --unstable-sloppy-imports integration.test.ts",
"setup-deps": "node setup-deps.js"
},
"dependencies": {
"@supabase/supabase-js": "file:../../"
}
}
Loading