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
312
-
cd ../../../ # Back to monorepo root
313
-
npx nx test:edge-functions supabase-js
314
-
```
315
-
316
-
**Important Notes:**
317
-
318
-
- The Edge Functions tests will fail with 503 errors if Supabase is not running
319
-
- If you encounter port conflicts (e.g., "port 54322 already allocated"), stop any existing Supabase instances:
320
-
321
-
```bash
322
-
npx supabase stop --project-id <project-name>
323
-
# Or stop all Docker containers if unsure:
324
-
docker ps | grep supabase # List all Supabase containers
325
-
```
326
-
327
-
- The tests use the default local development credentials (anon key)
328
-
- Edge Functions are automatically served when `supabase start` is run
329
-
330
-
#### Bun Testing
331
-
332
-
```bash
333
-
# Prerequisites:
334
-
# 1. Bun must be installed (https://bun.sh)
335
-
# 2. Supabase must be running (see Prerequisites)
336
-
# 3. Update test dependencies:
337
-
npx nx update:test-deps:bun supabase-js
338
-
339
-
# Run Bun tests
340
-
npx nx test:bun supabase-js
341
-
```
342
-
343
-
#### WebSocket Browser Testing
344
-
345
-
```bash
346
-
# Prerequisites:
347
-
# 1. Supabase must be running (see Prerequisites)
348
-
# 2. Build the UMD bundle first:
349
-
npx nx build supabase-js
350
-
351
-
# Run WebSocket browser tests with Playwright
352
-
cd packages/core/supabase-js/test/integration/node-browser
353
-
npm install
354
-
cp ../../../dist/umd/supabase.js .
355
-
npm run test
356
-
cd ../../..
357
-
```
358
-
359
-
#### CI/CD Testing
360
-
361
-
When running on CI, the tests automatically use the latest dependencies from the root project. The CI pipeline:
362
-
363
-
1. Builds the main project with current dependencies
364
-
2. Creates a package archive (`.tgz`) with the latest versions
365
-
3. Uses this archive in Expo, Next.js, Deno, and Bun tests to ensure consistency
366
-
367
-
### Updating Test Dependencies
368
-
369
-
The platform-specific tests (Expo, Next.js, Deno, Bun) use a packaged version of supabase-js rather than directly importing from source. This ensures they test the actual built package as it would be consumed by users.
370
-
371
-
#### How It Works
372
-
373
-
1.**Build** the current supabase-js package
374
-
2.**Pack** it into a `.tgz` file (like `npm pack` does)
375
-
3.**Copy** the `.tgz` to the test directory
376
-
4.**Install** it in the test project
377
-
378
-
This mimics how real users would install and use the package.
379
-
380
-
#### Update Scripts
381
-
382
-
```bash
383
-
# Update ALL test environment dependencies at once
384
-
# This builds, packs, and installs in all test directories
385
-
npx nx update:test-deps supabase-js
386
-
387
-
# Or update specific test environments:
388
-
npx nx update:test-deps:expo supabase-js # Expo/React Native only
389
-
npx nx update:test-deps:next supabase-js # Next.js only
390
-
npx nx update:test-deps:deno supabase-js # Deno only
391
-
npx nx update:test-deps:bun supabase-js # Bun only
392
-
```
393
-
394
-
**When to Update:**
395
-
396
-
- After making changes to the source code
397
-
- Before running platform-specific tests locally
398
-
- When debugging test failures that might be due to stale dependencies
399
-
400
-
**Note:** CI automatically handles this, so manual updates are only needed for local development.
401
-
402
-
### Test Coverage
403
-
404
-
#### Viewing Coverage Reports
405
-
406
-
```bash
407
-
# Generate coverage report
408
-
npx nx test:coverage supabase-js
409
-
410
-
# Serve coverage report locally (opens interactive HTML report)
411
-
npx nx serve:coverage supabase-js
412
-
# This starts a local server at http://localhost:3000 with the coverage report
413
-
```
414
-
415
-
The coverage report shows:
416
-
417
-
- Line coverage
418
-
- Branch coverage
419
-
- Function coverage
420
-
- Uncovered lines with highlights
421
-
422
-
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