The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
separated out integration tests for table listening and eventType listeneing
awalias258d0a035882
diff --git a/libraries/supabase-js/package.json b/libraries/supabase-js/package.jsonindex 400c783112e..0ccb918f0cb 100644--- a/libraries/supabase-js/package.json+++ b/libraries/supabase-js/package.json@@ -6,7 +6,7 @@"scripts": {"clean": "rimraf lib","test": "npm run cover",- "test:integration": "docker-compose -f ./test/docker-compose.yml up -d && sleep 5 && mocha --require babel-core/register --require babel-polyfill test/integration/**/*.js ; docker-compose -f ./test/docker-compose.yml down",+ "test:integration": "docker-compose -f ./test/docker-compose.yml up -d && sleep 10 && mocha --require babel-core/register --require babel-polyfill test/integration/**/*.js ; docker-compose -f ./test/docker-compose.yml down","test:prod": "cross-env BABEL_ENV=production npm run test","test:only": "mocha --require babel-core/register --require babel-polyfill --recursive","test:watch": "npm test -- --watch",diff --git a/libraries/supabase-js/test/docker-compose.yml b/libraries/supabase-js/test/docker-compose.ymlindex fca3652225d..3f6ae3e226e 100644--- a/libraries/supabase-js/test/docker-compose.yml+++ b/libraries/supabase-js/test/docker-compose.yml@@ -2,7 +2,7 @@ version: '3'services:supabase:- image: supabase/supabase-dev:0.1.4+ image: supabase/supabase-dev:0.1.5ports:- "8000:8000"environment:diff --git a/libraries/supabase-js/test/integration/testRealtime.js b/libraries/supabase-js/test/integration/testRealtime.jsindex edb8335ddd6..6a655a459af 100644--- a/libraries/supabase-js/test/integration/testRealtime.js+++ b/libraries/supabase-js/test/integration/testRealtime.js@@ -6,37 +6,77 @@ import { createClient } from '../../src'// unsubscribe()// removeSubscription()// getSubscriptions()-describe('test subscribing to an insert', () => {+describe('test subscribing to an insert', function () {const supabase = createClient('http://localhost:8000', 'examplekey')- it('on() and subscribe()', done => {- const callbackAction = record => {- console.log('Assert made')+ afterEach(function() {+ const subscriptions = supabase.getSubscriptions()+ for (const sub of subscriptions) {+ supabase.removeSubscription(sub)+ }+ })++ // test double wildcard, all events, all tables+ it('from(*).on(*).subscribe()', function (done) {+ const callbackAction = function(record) {assert(record.new.message === 'hello, mocha', 'inserted message is incorrect')done()}+ const subscription = supabase+ .from('*')+ .on('*', callbackAction)+ .subscribe()- // subscribe+ subscription.channel.socket.conn.addEventListener('open', function (event) {+ supabase+ .from('messages')+ .insert([{ message: 'hello, mocha', user_id: 1, channel_id: 1 }])+ .then()+ .catch(console.error)+ });+ }).timeout(15000)++ // test events on specific table+ it('from("messages").on("*").subscribe()', function (done) {+ const callbackAction = function(record) {+ assert(record.new.message === 'hello, mocha fans', 'inserted message is incorrect')+ done()+ }const subscription = supabase.from('messages')- .on('INSERT', callbackAction)+ .on('*', callbackAction).subscribe()- // make sure message only being sent after channel open- subscription.socket.conn.addEventListener('open', (event) => {- console.log("SAQCET OPEN")+ subscription.channel.socket.conn.addEventListener('open', function (event) {supabase.from('messages')- .insert([{ message: 'hello, mocha', user_id: 1, channel_id: 1 }])- .then(console.log)+ .insert([{ message: 'hello, mocha fans', user_id: 1, channel_id: 1 }])+ .then().catch(console.error)});+ }).timeout(15000)- // prove that the binding is on the channel- setTimeout(()=>console.log(subscription.channel.bindings[3].callback.toString()), 5000)+ // test on INSERT+ it('from("*").on("INSERT").subscribe()', function (done) {+ const callbackAction = function(record) {+ assert(record.new.message === 'hello, mocha fans, Y2K', 'inserted message is incorrect')+ done()+ }+ const subscription = supabase+ .from('*')+ .on('INSERT', callbackAction)+ .subscribe()++ subscription.channel.socket.conn.addEventListener('open', function (event) {+ supabase+ .from('messages')+ .insert([{ message: 'hello, mocha fans, Y2K', user_id: 1, channel_id: 1 }])+ .then()+ .catch(console.error)+ });}).timeout(15000)})-after(async () => {+after(function() {setTimeout(() => process.exit(0), 5000)})