From 6b8dfa1a3a89cfdef08c5c65c15f2abf1b66551b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=BB=BA=E5=BD=A4?= Date: Tue, 10 Nov 2026 21:28:17 +0800 Subject: [PATCH] test(doctor): reset modules before applying the driver mock The doctor Memory Persistence Driver suite can run after another file already imported doctor.ts in the same worker. Its vi.doMock('better-sqlite3') then does not affect the cached module, so the Memory Integrity check reports pass instead of the expected warn; the full CI ratchet has hit this intermittently.\n\nReset the module registry inside runDoctor() before importing doctor.ts, so the current test's mock always applies. The targeted binding-failure case passes; the rest of the file's local failures are the known Windows missing-native-binding environment. --- .../cli/__tests__/doctor-memory-driver-3321.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v3/@claude-flow/cli/__tests__/doctor-memory-driver-3321.test.ts b/v3/@claude-flow/cli/__tests__/doctor-memory-driver-3321.test.ts index 0f1250e41c..36c4c95d43 100644 --- a/v3/@claude-flow/cli/__tests__/doctor-memory-driver-3321.test.ts +++ b/v3/@claude-flow/cli/__tests__/doctor-memory-driver-3321.test.ts @@ -13,6 +13,10 @@ let workdir: string; let dbPath: string; async function runDoctor() { + // Full-suite isolation (#4643): this worker may already have imported + // doctor.ts before the current test registered its vi.doMock. Re-import a + // fresh module so the mock applies to its Memory Integrity check. + vi.resetModules(); const { doctorCommand } = await import('../src/commands/doctor.js'); const result = await doctorCommand.action!({ flags: { component: 'memory' }, args: [], config: {},