You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Important:** The test suite includes tests for multiple runtime environments (Node.js, Deno, Bun, Expo, Next.js). Each environment has its own test runner and specific requirements.
150
-
151
-
#### Prerequisites for All Integration Tests
152
-
153
-
1.**Docker** must be installed and running
154
-
2.**Supabase CLI** must be installed (`npm install -g supabase` or via package manager)
155
-
3.**Local Supabase instance** must be started:
156
-
157
-
```bash
158
-
# Navigate to the supabase-js package directory
159
-
cd packages/core/supabase-js
160
-
161
-
# Start Supabase (downloads and starts all required containers)
# 4. Run the Edge Functions tests from the monorepo root
317
-
cd ../../../ # Back to monorepo root
318
-
npx nx test:edge-functions supabase-js
319
-
```
320
-
321
-
**Important Notes:**
322
-
323
-
- The Edge Functions tests will fail with 503 errors if Supabase is not running
324
-
- If you encounter port conflicts (e.g., "port 54322 already allocated"), stop any existing Supabase instances:
325
-
326
-
```bash
327
-
npx supabase stop --project-id <project-name>
328
-
# Or stop all Docker containers if unsure:
329
-
docker ps | grep supabase # List all Supabase containers
330
-
```
331
-
332
-
- The tests use the default local development credentials (anon key)
333
-
- Edge Functions are automatically served when `supabase start` is run
334
-
335
-
#### Bun Testing
336
-
337
-
**Note:** For testing with local changes, use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above.
338
-
339
-
```bash
340
-
# Prerequisites:
341
-
# 1. Bun must be installed (https://bun.sh)
342
-
# 2. Supabase must be running (see Prerequisites)
343
-
# 3. Packages published to Verdaccio (see Verdaccio section)
344
-
345
-
# Run Bun tests
346
-
npx nx test:bun supabase-js
347
-
```
348
-
349
-
#### Running Integration Tests Locally with Verdaccio
350
-
351
-
For the most accurate testing that mirrors CI exactly, use a local Verdaccio registry. This approach:
352
-
- Tests the actual published package (not just source code)
353
-
- Mirrors the exact CI workflow
354
-
- Works for all integration test types (Next.js, Expo, Bun, Deno)
355
-
356
-
**Setup:**
357
-
358
-
```bash
359
-
# Terminal 1: Start local Verdaccio registry (stays running)
360
-
npx nx local-registry
361
-
362
-
# Terminal 2: Build and publish packages to local registry
363
-
npx nx run-many --target=build --all
364
-
npx nx populate-local-registry
365
-
```
366
-
367
-
**Run Integration Tests:**
368
-
369
-
```bash
370
-
# Example: Test with Bun
371
-
cd packages/core/supabase-js/test/integration/bun
372
-
echo'registry=http://localhost:4873/'> .npmrc
373
-
bun install
374
-
bun test
375
-
rm .npmrc # Clean up
376
-
cd ../../../..
377
-
378
-
# Example: Test with Next.js
379
-
cd packages/core/supabase-js/test/integration/next
380
-
echo'registry=http://localhost:4873/'> .npmrc
381
-
npm install --legacy-peer-deps
382
-
npm test
383
-
rm .npmrc
384
-
cd ../../../..
385
-
386
-
# Example: Test with Expo
387
-
cd packages/core/supabase-js/test/integration/expo
388
-
echo'registry=http://localhost:4873/'> .npmrc
389
-
npm install
390
-
npm test
391
-
rm .npmrc
392
-
cd ../../../..
393
-
394
-
# Example: Test with Deno
395
-
cd packages/core/supabase-js/test/deno
396
-
echo'registry=http://localhost:4873/'> .npmrc
397
-
npm install
398
-
npm test
399
-
rm .npmrc
400
-
cd ../../../..
401
-
```
402
-
403
-
**Tips:**
404
-
- Keep Verdaccio running in Terminal 1 for multiple test runs
405
-
- Only rebuild/republish when you change source code
406
-
- Registry runs on `http://localhost:4873/`
407
-
- To stop Verdaccio: Ctrl+C in Terminal 1
408
-
409
-
#### WebSocket Browser Testing
410
-
411
-
```bash
412
-
# Prerequisites:
413
-
# 1. Supabase must be running (see Prerequisites)
414
-
# 2. Build the UMD bundle first:
415
-
npx nx build supabase-js
416
-
417
-
# Run WebSocket browser tests with Playwright
418
-
cd packages/core/supabase-js/test/integration/node-browser
419
-
npm install
420
-
cp ../../../dist/umd/supabase.js .
421
-
npm run test
422
-
cd ../../..
423
-
```
424
-
425
-
#### CI/CD Testing
426
-
427
-
When running on CI, the tests automatically publish packages to a local Verdaccio registry. The CI pipeline:
428
-
429
-
1. Builds all packages with current dependencies
430
-
2. Starts a local Verdaccio registry
431
-
3. Publishes all packages to Verdaccio
432
-
4. Integration tests install from Verdaccio, ensuring they test the actual built packages
433
-
434
-
### Local Testing with Your Changes
435
-
436
-
The platform-specific tests (Expo, Next.js, Deno, Bun) install from registries rather than directly importing from source. This ensures they test the actual built packages as they would be consumed by users.
437
-
438
-
**For local development:** Use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above. This mirrors CI exactly and allows you to test your local changes before pushing.
439
-
440
-
### Test Coverage
441
-
442
-
#### Viewing Coverage Reports
443
-
444
-
```bash
445
-
# Generate coverage report
446
-
npx nx test:coverage supabase-js
447
-
448
-
# Serve coverage report locally (opens interactive HTML report)
449
-
npx nx serve:coverage supabase-js
450
-
# This starts a local server at http://localhost:3000 with the coverage report
451
-
```
452
-
453
-
The coverage report shows:
454
-
455
-
- Line coverage
456
-
- Branch coverage
457
-
- Function coverage
458
-
- Uncovered lines with highlights
459
-
460
-
Coverage results are also automatically uploaded to Coveralls in CI for tracking over time.
149
+
Please read our [testing guide](./TESTING.md) for detailed instructions on how to run your tests locally.
0 commit comments