Skip to content

Commit a9dffc2

Browse files
authored
chore(repo): update llm testing rules (#1932)
1 parent e168922 commit a9dffc2

File tree

4 files changed

+225
-127
lines changed

4 files changed

+225
-127
lines changed

.cursorrules

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This monorepo contains 6 JavaScript/TypeScript libraries previously maintained a
1717
1. **Zero Breaking Changes**: All migrations and changes must maintain full backward compatibility for consumers
1818
2. **Fixed Version Mode**: All packages share the same version number and are released together
1919
3. **Workspace Dependencies**: Internal dependencies use `*` which Nx replaces with actual versions during release
20-
4. **Affected Testing**: Always use `nx affected` commands to test only what changed
20+
4. **Complete Test Suites**: Use complete test suites for packages individually (`nx test:auth auth-js`, `nx test:storage storage-js`, etc.)
2121
5. **Conventional Commits**: Use conventional commit format for automated versioning and changelogs
2222

2323
## Common Commands
@@ -29,12 +29,14 @@ This monorepo contains 6 JavaScript/TypeScript libraries previously maintained a
2929
- Watch mode: `nx build auth-js --watch`
3030

3131
### Testing
32-
- Test all: `nx run-many --target=test --all`
33-
- Test specific: `nx test auth-js` (some packages may have special targets like `nx test:auth auth-js` or `nx test:storage storage-js`)
34-
- Test affected: `nx affected --target=test` (recommended for efficiency)
35-
- Integration tests: `nx run-many --target=test:integration --all`
36-
- Watch mode: `nx test <package> --watch`
37-
- Coverage: `nx test <package> --coverage`
32+
- Test specific (complete suites with Docker setup/cleanup):
33+
- `nx test:auth auth-js` - Complete auth-js test suite
34+
- `nx test:storage storage-js` - Complete storage-js test suite
35+
- `nx test:ci:postgrest postgrest-js` - Complete postgrest-js test suite
36+
- `nx test functions-js` - Standard test (uses testcontainers)
37+
- `nx test realtime-js` - Standard test (no Docker)
38+
- `nx test supabase-js` - Standard test (unit tests only)
39+
- supabase-js additional: `nx test:all`, `nx test:unit`, `nx test:integration`, `nx test:integration:browser`, `nx test:edge-functions`, `nx test:deno`, `nx test:bun`, `nx test:expo`, `nx test:next`, `nx test:node:playwright`, `nx test:types`
3840

3941
### Code Quality
4042
- Lint all: `nx run-many --target=lint --all`
@@ -52,20 +54,20 @@ This monorepo contains 6 JavaScript/TypeScript libraries previously maintained a
5254
When making changes that affect multiple libraries:
5355
1. Make all changes in a single PR
5456
2. Update tests in both source library and integration tests in supabase-js
55-
3. Use `nx affected --target=test` to verify all impacts
57+
3. Run complete test suites for affected packages to verify all impacts
5658
4. Commit with clear scope: `fix(realtime-js): resolve connection issue`
5759

5860
### Adding New Features
5961
1. Implement in the specific library under `packages/core/[library-name]`
6062
2. Add comprehensive unit tests in the library's `test/` directory
6163
3. If it affects supabase-js, add integration tests there
62-
4. Run `nx affected --target=test` before committing
64+
4. Run complete test suite for the package before committing
6365

6466
### Quick Fixes
6567
Even for single-library fixes:
6668
1. Use conventional commit: `fix(storage-js): correct upload timeout`
6769
2. All packages will be versioned together (fixed mode)
68-
3. Run `nx affected --target=test`
70+
3. Run complete test suite for the package
6971
4. Changes ship together in next release
7072

7173
## TypeScript Configuration
@@ -85,9 +87,15 @@ The workspace uses strict TypeScript settings:
8587
- Mock external dependencies
8688

8789
### Integration Tests
88-
- Libraries with external services (auth-js, storage-js) use Docker
89-
- Docker Compose configs in `infra/` directories
90-
- Run with: `npm run test:infra` from library directory
90+
- Libraries with external services (auth-js, storage-js, postgrest-js, functions-js) use Docker
91+
- Complete test suites handle Docker setup/cleanup automatically:
92+
- `nx test:auth auth-js` - Handles Docker lifecycle
93+
- `nx test:storage storage-js` - Handles Docker lifecycle
94+
- `nx test:ci:postgrest postgrest-js` - Handles Docker lifecycle
95+
- Manual infrastructure management available:
96+
- `nx test:infra auth-js` / `nx test:suite auth-js` / `nx test:clean auth-js`
97+
- `nx test:infra storage-js` / `nx test:suite storage-js` / `nx test:clean storage-js`
98+
- `nx db:run postgrest-js` / `nx test:run postgrest-js` / `nx db:clean postgrest-js`
9199

92100
### Cross-Platform Tests
93101
The main supabase-js tests against:
@@ -116,7 +124,12 @@ packages/core/[library-name]/
116124
- **Package Names**: All packages maintain original npm names (@supabase/[package-name])
117125
- **Shared Code**: Extract common patterns (HTTP client, error handling) to shared packages when identified
118126
- **Docker Required**: Integration tests for auth-js, functions-js, postgrest-js, and storage-js require Docker to be running
119-
- **Special Test Commands**: Some packages may use special test targets (check individual package READMEs)
127+
- **Complete Test Commands**: Use complete test suites that handle Docker automatically:
128+
- `nx test:auth auth-js` - Complete auth-js test suite
129+
- `nx test:storage storage-js` - Complete storage-js test suite
130+
- `nx test:ci:postgrest postgrest-js` - Complete postgrest-js test suite
131+
- `nx test functions-js` - Standard test (uses testcontainers)
132+
- **Individual Commands**: Available for manual infrastructure management (see package READMEs)
120133

121134
## Release Process
122135

@@ -160,10 +173,11 @@ The `*` is replaced with actual version during release.
160173

161174
1. Always consider the monorepo structure - changes might affect multiple packages
162175
2. Use Nx commands rather than npm/yarn directly for workspace operations
163-
3. Suggest running affected tests (`nx affected --target=test`), not all tests, for better performance
176+
3. Suggest running complete test suites for affected packages individually
164177
4. Remember that all packages version together in fixed mode - no independent versioning
165178
5. Consider Docker requirements for integration tests (auth-js, functions-js, postgrest-js, storage-js)
166179
6. Maintain backward compatibility at all costs - breaking changes require special process
167-
7. Check for special test commands in package READMEs (some may use `test:auth`, `test:storage`, etc.)
180+
7. Use complete test suites for packages with Docker: `nx test:auth auth-js`, `nx test:storage storage-js`, `nx test:ci:postgrest postgrest-js`
181+
8. Check package READMEs for all available test commands and individual infrastructure management options
168182
8. Always suggest conventional commit format with proper scope
169-
9. Prefer `nx affected` commands over `nx run-many` for efficiency
183+
9. Run complete test suites for packages individually rather than trying to run all tests together

CLAUDE.md

Lines changed: 103 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,48 @@ nx build auth-js --watch # Development mode
124124
### Testing
125125

126126
```bash
127-
nx run-many --target=test --all # Test all packages
128-
nx test auth-js # Test specific package
129-
nx test postgrest-js # Test specific package
130-
nx test functions-js # Test specific package
131-
nx test realtime-js # Test specific package
132-
nx test storage-js # Test specific package (may use special test:storage target)
133-
nx test supabase-js # Test specific package
134-
nx affected --target=test # Test only affected (recommended)
135-
nx test auth-js --watch # Watch mode
136-
nx test supabase-js --coverage # Test with coverage
127+
# Test specific packages (complete test suites with Docker setup/cleanup)
128+
nx test:auth auth-js # Complete auth-js test suite (handles Docker)
129+
nx test:storage storage-js # Complete storage-js test suite (handles Docker)
130+
nx test:ci:postgrest postgrest-js # Complete postgrest-js test suite (handles Docker)
131+
nx test functions-js # Standard test (uses testcontainers)
132+
nx test realtime-js # Standard test (no Docker needed)
133+
nx test supabase-js # Standard test (unit tests only)
134+
135+
# Coverage reports
136+
nx test supabase-js --coverage
137+
nx test:coverage realtime-js
138+
nx test:ci functions-js # Includes coverage
137139
```
138140

139141
**Docker Requirements:**
140142

141-
| Package | Docker Required | Infrastructure | Special Commands |
142-
| ------------ | --------------- | ------------------------------- | ------------------------------------ |
143-
| auth-js | ✅ Yes | Auth Server + Postgres | May use `nx test:auth auth-js` |
144-
| functions-js | ✅ Yes | Deno relay (testcontainers) | Standard `nx test functions-js` |
145-
| postgrest-js | ✅ Yes | PostgREST + PostgreSQL | Standard `nx test postgrest-js` |
146-
| storage-js | ✅ Yes | Storage API + PostgreSQL + Kong | May use `nx test:storage storage-js` |
147-
| realtime-js | ❌ No | Mock WebSockets | Standard `nx test realtime-js` |
148-
| supabase-js | ❌ No | Unit tests only | Standard `nx test supabase-js` |
143+
| Package | Docker Required | Infrastructure | Complete Test Command | Individual Commands |
144+
| ------------ | --------------- | ------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------- |
145+
| auth-js | ✅ Yes | Auth Server + Postgres | `nx test:auth auth-js` | `nx test:suite auth-js`, `nx test:infra auth-js`, `nx test:clean auth-js` |
146+
| storage-js | ✅ Yes | Storage API + PostgreSQL + Kong | `nx test:storage storage-js` | `nx test:suite storage-js`, `nx test:infra storage-js`, `nx test:clean storage-js` |
147+
| postgrest-js | ✅ Yes | PostgREST + PostgreSQL | `nx test:ci:postgrest postgrest-js` | `nx test:run postgrest-js`, `nx test:update postgrest-js`, `nx test:types postgrest-js` |
148+
| functions-js | ✅ Yes | Deno relay (testcontainers) | `nx test functions-js` | `nx test:ci functions-js` (with coverage) |
149+
| realtime-js | ❌ No | Mock WebSockets | `nx test realtime-js` | `nx test:coverage realtime-js`, `nx test:watch realtime-js` |
150+
| supabase-js | ❌ No | Unit tests only | `nx test supabase-js` | `nx test:all`, `nx test:unit`, `nx test:integration`, `nx test:coverage`, `nx test:watch` |
151+
152+
**supabase-js Additional Test Commands:**
153+
154+
```bash
155+
nx test:all supabase-js # Unit + integration + browser tests
156+
nx test:unit supabase-js # Jest unit tests only
157+
nx test:integration supabase-js # Node.js integration tests
158+
nx test:integration:browser supabase-js # Browser tests (requires Deno)
159+
nx test:edge-functions supabase-js # Edge Functions tests
160+
nx test:deno supabase-js # Deno runtime tests
161+
nx test:bun supabase-js # Bun runtime tests
162+
nx test:expo supabase-js # React Native/Expo tests
163+
nx test:next supabase-js # Next.js SSR tests
164+
nx test:node:playwright supabase-js # WebSocket browser tests
165+
nx test:types supabase-js # TypeScript type checking
166+
nx test:coverage supabase-js # Coverage report
167+
nx test:watch supabase-js # Watch mode
168+
```
149169

150170
> **📖 See [TESTING.md](docs/TESTING.md) for complete testing guide and troubleshooting**
151171
@@ -177,7 +197,7 @@ nx affected --graph # Visualize affected projects
177197
1. Fix root cause in `packages/core/realtime-js/src/`
178198
2. Add unit test in `packages/core/realtime-js/test/`
179199
3. Add integration test in `packages/core/supabase-js/test/`
180-
4. Run `nx affected --target=test` to verify both packages
200+
4. Run complete test suites for both packages to verify impacts
181201
5. Commit: `fix(realtime-js): resolve reconnection logic affecting supabase-js`
182202
6. Single PR, single review, single release - all packages version together
183203

@@ -187,7 +207,7 @@ nx affected --graph # Visualize affected projects
187207
2. Write comprehensive unit tests in `packages/core/[library]/test/`
188208
3. If feature affects supabase-js, add integration tests there
189209
4. Update TypeScript types if needed
190-
5. Run `nx affected --target=test` before committing
210+
5. Run complete test suite for the package before committing
191211
6. Use conventional commit: `feat(storage-js): add resumable uploads`
192212

193213
### Quick Fix Workflow
@@ -197,7 +217,8 @@ nx affected --graph # Visualize affected projects
197217
git add .
198218
git commit -m "fix(auth-js): correct session expiry calculation"
199219
# → Automatic canary: 2.80.1-canary.0 published to 'canary' dist-tag
200-
nx affected --target=test
220+
# Run complete test suite for the package:
221+
nx test:auth auth-js
201222
# After validation, manual promotion:
202223
nx release --tag=latest --yes # Promotes to stable with same version for ALL packages
203224
```
@@ -289,13 +310,36 @@ This repository uses TypeScript project references for incremental builds and be
289310

290311
### Integration Tests (Docker-based)
291312

292-
**Auth-JS & Storage-JS**:
313+
**Complete Test Suites (Recommended)**:
293314

294315
```bash
295-
cd packages/core/auth-js
296-
npm run test:infra # Start Docker containers
297-
npm run test:suite # Run tests
298-
npm run test:clean # Cleanup
316+
# Auth-js: Complete test suite (handles Docker setup/cleanup automatically)
317+
nx test:auth auth-js
318+
319+
# Storage-js: Complete test suite (handles Docker setup/cleanup automatically)
320+
nx test:storage storage-js
321+
322+
# Postgrest-js: Complete test suite (handles Docker setup/cleanup automatically)
323+
nx test:ci:postgrest postgrest-js
324+
```
325+
326+
**Manual Infrastructure Management** (for development):
327+
328+
```bash
329+
# Auth-js
330+
nx test:infra auth-js # Start Docker containers
331+
nx test:suite auth-js # Run tests (can run multiple times)
332+
nx test:clean auth-js # Cleanup
333+
334+
# Storage-js
335+
nx test:infra storage-js # Start Docker containers
336+
nx test:suite storage-js # Run tests (can run multiple times)
337+
nx test:clean storage-js # Cleanup
338+
339+
# Postgrest-js
340+
nx db:run postgrest-js # Start containers
341+
nx test:run postgrest-js # Run tests
342+
nx db:clean postgrest-js # Cleanup
299343
```
300344

301345
### Cross-Platform Tests (supabase-js)
@@ -443,21 +487,27 @@ cd packages/core/auth-js && npm test
443487
✅ Correct:
444488

445489
```bash
446-
nx test auth-js
490+
nx test:auth auth-js
447491
```
448492

449493
### Pitfall 3: Testing Everything
450494

451495
❌ Wrong:
452496

453497
```bash
454-
nx run-many --target=test --all # Slow, tests unchanged code
498+
nx run-many --target=test --all # Won't work - no standard test target for all packages
455499
```
456500

457501
✅ Correct:
458502

459503
```bash
460-
nx affected --target=test # Fast, tests only changes
504+
# Run complete test suite for the specific package
505+
nx test:auth auth-js
506+
nx test:storage storage-js
507+
nx test:ci:postgrest postgrest-js
508+
nx test functions-js
509+
nx test realtime-js
510+
nx test supabase-js
461511
```
462512

463513
### Pitfall 4: Breaking Changes
@@ -505,7 +555,7 @@ npm run build
505555
✅ Correct: Use Nx commands from repository root
506556

507557
```bash
508-
nx test auth-js
558+
nx test:auth auth-js
509559
nx build auth-js --watch
510560
```
511561

@@ -528,7 +578,7 @@ npm run commit # Guides you through proper format
528578
❌ Wrong: Assuming you know how to run tests without checking
529579

530580
```bash
531-
nx test storage-js # Might fail if Docker isn't running
581+
nx test storage-js # Wrong - should use nx test:storage storage-js
532582
```
533583

534584
✅ Correct: Check library README and TESTING.md first
@@ -559,7 +609,10 @@ cat docs/TESTING.md
559609

560610
```bash
561611
nx format # Format code
562-
nx affected --target=test # Test affected packages
612+
# Run complete test suite for affected packages individually
613+
nx test:auth auth-js # If auth-js changed
614+
nx test:storage storage-js # If storage-js changed
615+
# ... etc for other packages
563616
nx affected --target=lint # Lint affected packages
564617
nx affected --target=build # Build affected packages
565618
```
@@ -601,7 +654,7 @@ Brief description of what this PR does
601654
## Checklist
602655

603656
- [ ] Code formatted (`nx format`)
604-
- [ ] Tests passing (`nx affected --target=test`)
657+
- [ ] Tests passing (run complete test suites for affected packages)
605658
- [ ] Builds passing (`nx affected --target=build`)
606659
- [ ] Used conventional commits
607660
- [ ] Documentation updated (if needed)
@@ -655,7 +708,10 @@ nx format
655708
npm run commit
656709

657710
# 6. Before pushing
658-
nx affected --target=test
711+
# Run complete test suite for the package you changed
712+
nx test:auth auth-js # If auth-js changed
713+
nx test:storage storage-js # If storage-js changed
714+
# ... etc
659715
nx affected --target=build
660716
nx format:check
661717

@@ -677,8 +733,9 @@ npm install
677733
# Check for errors
678734
nx run-many --target=lint --all
679735

680-
# Run specific test file
681-
nx test auth-js --testFile=GoTrueClient.test.ts
736+
# Run specific test file (for packages with standard test target)
737+
nx test realtime-js --testFile=RealtimeClient.test.ts
738+
nx test supabase-js --testFile=client.test.ts
682739
```
683740

684741
## Additional Resources
@@ -715,7 +772,7 @@ git commit -m "fix(auth): resolve token issue"
715772

716773
```bash
717774
# 1. Validate canary version
718-
nx affected --target=test
775+
# Run complete test suites for packages individually
719776

720777
# 2. Preview stable promotion
721778
nx release --dry-run
@@ -805,7 +862,7 @@ _No user-facing changes in this release._
805862

806863
1. **Consider Monorepo Impact**: Changes might affect multiple packages - always check dependencies
807864
2. **Use Nx Commands**: Always prefer `nx` over direct `npm` for workspace operations
808-
3. **Suggest Affected Testing**: Use `nx affected --target=test` over full test suite for efficiency
865+
3. **Suggest Complete Test Suites**: Use complete test suites (`nx test:auth auth-js`, `nx test:storage storage-js`, etc.) for packages individually
809866
4. **Respect Fixed Versioning**: All packages version together - no independent versioning
810867
5. **Maintain Compatibility**: Never introduce breaking changes without proper process
811868
6. **Check Testing Requirements**: Be aware of Docker requirements for integration tests
@@ -830,8 +887,14 @@ _No user-facing changes in this release._
830887

831888
1. Unit test in source library
832889
2. Integration test in supabase-js if affects it
833-
3. Run `nx affected --target=test`
834-
4. Check if Docker needed (auth-js, storage-js)
890+
3. Run complete test suite for the package:
891+
- `nx test:auth auth-js` (handles Docker automatically)
892+
- `nx test:storage storage-js` (handles Docker automatically)
893+
- `nx test:ci:postgrest postgrest-js` (handles Docker automatically)
894+
- `nx test functions-js` (uses testcontainers)
895+
- `nx test realtime-js` (no Docker needed)
896+
- `nx test supabase-js` (unit tests only)
897+
4. Run complete test suites for all affected packages individually
835898

836899
**Q: How will this release?**
837900

0 commit comments

Comments
 (0)