Skip to content

Backend testing guide and mocking patterns #566

Description

@codebestia

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions