Skip to content

Commit 18d4fab

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

File tree

2 files changed

+88
-55
lines changed

2 files changed

+88
-55
lines changed

packages/core/supabase-js/README.md

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -245,46 +245,51 @@ npx nx test:all supabase-js
245245

246246
#### Expo Testing (React Native)
247247

248+
**Note:** For testing with local changes, use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above.
249+
248250
```bash
249251
# Prerequisites:
250252
# 1. Supabase must be running (see Prerequisites)
251-
# 2. Update test dependencies and pack current build
252-
cd packages/core/supabase-js
253-
npm run update:test-deps:expo
253+
# 2. Packages published to Verdaccio (see Verdaccio section)
254254

255255
# Run Expo tests from the Expo test project
256-
cd test/integration/expo
256+
cd packages/core/supabase-js/test/integration/expo
257+
echo 'registry=http://localhost:4873/' > .npmrc
257258
npm install
258259
npm test
259-
cd ../../..
260+
rm .npmrc
261+
cd ../../../..
260262
```
261263

262264
#### Next.js Testing (SSR)
263265

266+
**Note:** For testing with local changes, use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above.
267+
264268
```bash
265269
# Prerequisites:
266270
# 1. Supabase must be running (see Prerequisites)
267-
# 2. Update test dependencies and pack current build
268-
npx nx update:test-deps:next supabase-js
269-
271+
# 2. Packages published to Verdaccio (see Verdaccio section)
270272
# 3. Install Playwright browsers and dependencies
271273
npx playwright install --with-deps
272274

273275
# Run Next.js tests from the Next test project
274276
cd packages/core/supabase-js/test/integration/next
277+
echo 'registry=http://localhost:4873/' > .npmrc
275278
npm install --legacy-peer-deps
276279
npm run test
277-
cd ../../..
280+
rm .npmrc
281+
cd ../../../..
278282
```
279283

280284
#### Deno Testing
281285

286+
**Note:** For testing with local changes, use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above.
287+
282288
```bash
283289
# Prerequisites:
284290
# 1. Deno must be installed (https://deno.land)
285291
# 2. Supabase must be running (see Prerequisites)
286-
# 3. Update test dependencies:
287-
npx nx update:test-deps:deno supabase-js
292+
# 3. Packages published to Verdaccio (see Verdaccio section)
288293

289294
# Run Deno tests
290295
npx nx test:deno supabase-js
@@ -329,17 +334,78 @@ npx nx test:edge-functions supabase-js
329334

330335
#### Bun Testing
331336

337+
**Note:** For testing with local changes, use the Verdaccio workflow described in "Running Integration Tests Locally with Verdaccio" above.
338+
332339
```bash
333340
# Prerequisites:
334341
# 1. Bun must be installed (https://bun.sh)
335342
# 2. Supabase must be running (see Prerequisites)
336-
# 3. Update test dependencies:
337-
npx nx update:test-deps:bun supabase-js
343+
# 3. Packages published to Verdaccio (see Verdaccio section)
338344

339345
# Run Bun tests
340346
npx nx test:bun supabase-js
341347
```
342348

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+
343409
#### WebSocket Browser Testing
344410

345411
```bash
@@ -358,46 +424,18 @@ cd ../../..
358424

359425
#### CI/CD Testing
360426

361-
When running on CI, the tests automatically use the latest dependencies from the root project. The CI pipeline:
427+
When running on CI, the tests automatically publish packages to a local Verdaccio registry. The CI pipeline:
362428

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-
```
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
393433

394-
**When to Update:**
434+
### Local Testing with Your Changes
395435

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
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.
399437

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

402440
### Test Coverage
403441

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)