@crossdelta/platform-sdk 0.3.41 → 0.3.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@
4
4
  "module": "ES2022",
5
5
  "moduleResolution": "Bundler",
6
6
  "strict": true,
7
+ "lib": ["ES2022"],
7
8
  "jsx": "react-jsx",
8
9
  "jsxImportSource": "hono/jsx",
9
10
  "esModuleInterop": true,
@@ -339,38 +339,39 @@ describe('Service Health Check', () => {
339
339
 
340
340
  #### `src/use-cases/business-logic.use-case.test.ts`
341
341
  ```typescript
342
- import { describe, expect, it, beforeEach, vi } from 'bun:test'
342
+ import { describe, expect, it } from 'bun:test'
343
343
  import { myUseCase } from './business-logic.use-case'
344
344
 
345
345
  describe('BusinessLogic Use Case', () => {
346
- beforeEach(() => {
347
- vi.clearAllMocks()
348
- })
349
-
350
346
  it('should handle valid input correctly', async () => {
351
347
  const result = await myUseCase({ id: '123' })
352
348
  expect(result).toBeDefined()
353
349
  })
354
350
 
355
351
  it('should throw error for invalid input', async () => {
356
- await expect(myUseCase({ id: '' })).rejects.toThrow()
352
+ await expect(myUseCase({ id: '' })).rejects.toThrow('Invalid input')
357
353
  })
358
354
  })
359
355
  ```
360
356
 
361
357
  **Test Guidelines:**
358
+ - **Keep tests simple and lightweight** - Bun's test runner is minimal, not a full-featured test framework
362
359
  - Write tests ONLY for use cases (NOT event handlers)
363
360
  - Event handlers are thin wrappers - the use cases contain the testable logic
364
- - Use Bun's native test runner: `import { describe, expect, it, beforeEach, afterEach, vi } from 'bun:test'`
365
- - Use `vi` from `bun:test` for mocking (NOT jest or vitest)
361
+ - Use Bun's native test runner: `import { describe, expect, it, beforeEach, afterEach } from 'bun:test'`
362
+ - **NO mocking available** - Bun's test runner does NOT have `vi`, `mock`, or similar utilities
363
+ - ❌ NO `vi` object (that's Vitest, not Bun)
364
+ - ❌ NO `jest.fn()` or `jest.mock()`
365
+ - ❌ NO module mocking
366
+ - ✅ Use simple, direct testing without mocks
366
367
  - Use descriptive test names in English
367
368
  - Test both happy paths and error cases
368
- - Focus on validation and error handling
369
- - DO NOT mock external libraries (Pusher, AWS SDK, etc.) - they are hard to mock correctly
369
+ - Focus on validation and error handling (input params, env vars)
370
+ - **DO NOT mock external libraries** - Bun doesn't support mocking, keep tests simple
370
371
  - Test environment variable validation and input validation
371
- - Use `beforeEach`/`afterEach` to clean up mocks: `vi.clearAllMocks()` or `vi.restoreAllMocks()`
372
+ - Keep cleanup simple in `afterEach`: restore `process.env` only
372
373
 
373
- **Example: Testing validation and error handling**
374
+ **Example: Simple validation and error handling tests**
374
375
  ```typescript
375
376
  import { describe, expect, it, beforeEach, afterEach } from 'bun:test'
376
377
  import { sendNotification } from './send-notification.use-case'
@@ -379,10 +380,12 @@ describe('Send Notification Use Case', () => {
379
380
  const originalEnv = process.env
380
381
 
381
382
  beforeEach(() => {
383
+ // Save original environment
382
384
  process.env = { ...originalEnv }
383
385
  })
384
386
 
385
387
  afterEach(() => {
388
+ // Restore original environment (no vi.resetModules needed)
386
389
  process.env = originalEnv
387
390
  })
388
391
 
@@ -402,6 +405,71 @@ describe('Send Notification Use Case', () => {
402
405
  })
403
406
  ```
404
407
 
408
+ **What to test:**
409
+ - ✅ Input validation (missing/empty parameters)
410
+ - ✅ Environment variable validation
411
+ - ✅ Error messages and error types
412
+ - ✅ Basic logic flows
413
+ - ❌ Complex mocking scenarios
414
+ - ❌ External API integrations (Pusher, AWS, etc.)
415
+ - ❌ Module reloading/resetting
416
+
417
+ **Test Strategy:**
418
+ - Focus on **validation** (input parameters, environment variables)
419
+ - Test **error handling** and edge cases
420
+ - Keep tests **simple** - avoid complex mocking of external libraries
421
+ - Test the **business logic**, not the external API calls
422
+ - If a function calls an external API, test the validation BEFORE the call, not the call itself
423
+
424
+ **Example of what NOT to do:**
425
+ ```typescript
426
+ // ❌ BAD - Trying to mock Pusher (not possible in Bun)
427
+ import { describe, expect, it, beforeEach, afterEach, vi } from 'bun:test'
428
+
429
+ describe('Bad Test', () => {
430
+ afterEach(() => {
431
+ vi.resetModules() // ❌ This doesn't exist in Bun!
432
+ })
433
+
434
+ it('should send notification', async () => {
435
+ // ❌ Trying to mock external library
436
+ const mockPusher = vi.fn() // ❌ vi doesn't exist!
437
+ })
438
+ })
439
+ ```
440
+
441
+ **Example of what TO do:**
442
+ ```typescript
443
+ // ✅ GOOD - Simple validation tests
444
+ import { describe, expect, it, beforeEach, afterEach } from 'bun:test'
445
+
446
+ describe('Good Test', () => {
447
+ const originalEnv = process.env
448
+
449
+ beforeEach(() => {
450
+ process.env = { ...originalEnv }
451
+ })
452
+
453
+ afterEach(() => {
454
+ process.env = originalEnv
455
+ })
456
+
457
+ it('should throw error if orderId is missing', async () => {
458
+ await expect(
459
+ sendNotification({ orderId: '', customerId: 'cust-1' })
460
+ ).rejects.toThrow('Missing orderId')
461
+ })
462
+
463
+ it('should throw error if credentials not set', async () => {
464
+ delete process.env.PUSHER_BEAMS_INSTANCE_ID
465
+
466
+ await expect(
467
+ sendNotification({ orderId: '123', customerId: 'cust-1' })
468
+ ).rejects.toThrow('Missing Pusher Beams credentials')
469
+ })
470
+ })
471
+ ```
472
+
405
473
  ### README
406
474
 
407
475
  Generate a service-specific README documenting:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.3.41",
3
+ "version": "0.3.42",
4
4
  "description": "CLI toolkit for scaffolding Turborepo workspaces with Pulumi infrastructure and Hono/NestJS microservices",
5
5
  "keywords": [
6
6
  "cli",