Write apps/backend/docs/testing.md: the backend-specific companion to the cross-app testing guide. The suite has strong, repeated conventions that are currently only learnable by reading dozens of files, and getting them wrong produces confusing failures rather than clear ones.
Acceptance criteria:
- Documents the standard mock set for a route test (
db/index.js, db/schema.js, drizzle-orm, lib/redis.js, middleware/auth.js) with a copyable skeleton
- Documents the socket-handler pattern: emit through the enveloped
dispatch event, and why grabbing a raw listener no longer works
- Explains the Drizzle chain-mocking traps —
.values() needing to be thenable and expose .returning()
- Documents that service mocks must be added when a route gains a new dependency
- Documents resetting shared in-process state (rate-limit counters) between tests
Write
apps/backend/docs/testing.md: the backend-specific companion to the cross-app testing guide. The suite has strong, repeated conventions that are currently only learnable by reading dozens of files, and getting them wrong produces confusing failures rather than clear ones.Acceptance criteria:
db/index.js,db/schema.js,drizzle-orm,lib/redis.js,middleware/auth.js) with a copyable skeletondispatchevent, and why grabbing a raw listener no longer works.values()needing to be thenable and expose.returning()