From b5b48e407e8c7d4f10cf3f25e80ee39ab863064d Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Sat, 25 Apr 2026 19:17:50 +0200 Subject: [PATCH] test(social): note the shared-state harness contract Per code-review suggestion: add a brief comment explaining why module-level sqlite/testDb/app reassignment works (mock getter closes over the current binding) and what would break it (top-level it, .concurrent describe). Prevents a future foot-gun. --- packages/server/src/routes/social.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/src/routes/social.test.ts b/packages/server/src/routes/social.test.ts index 5381b5be..7efe6790 100644 --- a/packages/server/src/routes/social.test.ts +++ b/packages/server/src/routes/social.test.ts @@ -13,6 +13,12 @@ setWorkerId(1); const __dirname = path.dirname(fileURLToPath(import.meta.url)); +// Module-level mutable state. Each describe's beforeEach reassigns +// `sqlite`/`testDb`/`app`; the `getDb: () => testDb` getter in the mock +// closes over the current binding, so reassignment is observed. Adding +// a top-level `it` (outside any describe) or switching to `.concurrent` +// would break this pattern — keep new tests inside a describe block +// that owns its own beforeEach reset. type TestDb = ReturnType>; let sqlite: Database.Database; let testDb: TestDb;