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.
This commit is contained in:
@@ -13,6 +13,12 @@ setWorkerId(1);
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
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<typeof drizzle<typeof schema>>;
|
type TestDb = ReturnType<typeof drizzle<typeof schema>>;
|
||||||
let sqlite: Database.Database;
|
let sqlite: Database.Database;
|
||||||
let testDb: TestDb;
|
let testDb: TestDb;
|
||||||
|
|||||||
Reference in New Issue
Block a user