Skip to content

Commit 12df5ec

Browse files
committed
chore(supabase): update readme and package.json testing instructions
1 parent 66387b1 commit 12df5ec

File tree

2 files changed

+69
-42
lines changed

2 files changed

+69
-42
lines changed

packages/core/supabase-js/README.md

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,66 @@ npx nx update:test-deps:bun supabase-js
340340
npx nx test:bun supabase-js
341341
```
342342

343+
#### Running Integration Tests Locally with Verdaccio
344+
345+
For the most accurate testing that mirrors CI exactly, use a local Verdaccio registry. This approach:
346+
- Tests the actual published package (not just source code)
347+
- Mirrors the exact CI workflow
348+
- Works for all integration test types (Next.js, Expo, Bun, Deno)
349+
350+
**Setup:**
351+
352+
```bash
353+
# Terminal 1: Start local Verdaccio registry (stays running)
354+
npx nx local-registry
355+
356+
# Terminal 2: Build and publish packages to local registry
357+
npx nx run-many --target=build --all
358+
npx nx populate-local-registry
359+
```
360+
361+
**Run Integration Tests:**
362+
363+
```bash
364+
# Example: Test with Bun
365+
cd packages/core/supabase-js/test/integration/bun
366+
echo 'registry=http://localhost:4873/' > .npmrc
367+
bun install
368+
bun test
369+
rm .npmrc # Clean up
370+
cd ../../../..
371+
372+
# Example: Test with Next.js
373+
cd packages/core/supabase-js/test/integration/next
374+
echo 'registry=http://localhost:4873/' > .npmrc
375+
npm install --legacy-peer-deps
376+
npm test
377+
rm .npmrc
378+
cd ../../../..
379+
380+
# Example: Test with Expo
381+
cd packages/core/supabase-js/test/integration/expo
382+
echo 'registry=http://localhost:4873/' > .npmrc
383+
npm install
384+
npm test
385+
rm .npmrc
386+
cd ../../../..
387+
388+
# Example: Test with Deno
389+
cd packages/core/supabase-js/test/deno
390+
echo 'registry=http://localhost:4873/' > .npmrc
391+
npm install
392+
npm test
393+
rm .npmrc
394+
cd ../../../..
395+
```
396+
397+
**Tips:**
398+
- Keep Verdaccio running in Terminal 1 for multiple test runs
399+
- Only rebuild/republish when you change source code
400+
- Registry runs on `http://localhost:4873/`
401+
- To stop Verdaccio: Ctrl+C in Terminal 1
402+
343403
#### WebSocket Browser Testing
344404

345405
```bash
@@ -358,46 +418,18 @@ cd ../../..
358418

359419
#### CI/CD Testing
360420

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
421+
When running on CI, the tests automatically publish packages to a local Verdaccio registry. The CI pipeline:
368422

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-
```
423+
1. Builds all packages with current dependencies
424+
2. Starts a local Verdaccio registry
425+
3. Publishes all packages to Verdaccio
426+
4. Integration tests install from Verdaccio, ensuring they test the actual built packages
393427

394-
**When to Update:**
428+
### Local Testing with Your Changes
395429

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
430+
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.
399431

400-
**Note:** CI automatically handles this, so manual updates are only needed for local development.
432+
**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.
401433

402434
### Test Coverage
403435

packages/core/supabase-js/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@
4444
"test:types": "tsd --files test/types/*.test-d.ts && jsr publish --dry-run --allow-dirty",
4545
"docs": "typedoc --entryPoints src/index.ts --out docs/v2",
4646
"docs:json": "typedoc --entryPoints src/index.ts --json docs/v2/spec.json --excludeExternals",
47-
"serve:coverage": "npx nx test:coverage supabase-js && serve test/coverage",
48-
"update:test-deps": "cd test/integration/expo && npm install && cd ../next && npm install --legacy-peer-deps && cd ../../deno && npm install && cd ../integration/bun && bun install",
49-
"update:test-deps:expo": "cd test/integration/expo && npm install",
50-
"update:test-deps:next": "cd test/integration/next && npm install --legacy-peer-deps",
51-
"update:test-deps:deno": "cd test/deno && npm install",
52-
"update:test-deps:bun": "cd test/integration/bun && bun install"
47+
"serve:coverage": "npx nx test:coverage supabase-js && serve test/coverage"
5348
},
5449
"dependencies": {
5550
"@supabase/auth-js": "*",

0 commit comments

Comments
 (0)