Skip to content

Commit 4f83ed7

Browse files
test(readFile): restore console.warn spy in afterEach to prevent leakage
Addresses CodeRabbit nitpick: several tests installed vi.spyOn(console, "warn") without restoring it, leaking the mock across tests. Added a scoped afterEach that restores console.warn only (via vi.isMockFunction guard) so the suite's module-level mocks are left intact. 75 tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c70b1a9 commit 4f83ed7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/core/tools/__tests__/readFileTool.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ describe("ReadFileTool", () => {
195195
})
196196
})
197197

198+
afterEach(() => {
199+
// Restore the console.warn spy that some tests install via vi.spyOn so it
200+
// doesn't leak into subsequent tests. Scoped to console to avoid restoring
201+
// the module-level mocks (e.g. ImageMemoryTracker) set up for the suite.
202+
if (vi.isMockFunction(console.warn)) {
203+
;(console.warn as ReturnType<typeof vi.spyOn>).mockRestore()
204+
}
205+
})
206+
198207
describe("input validation", () => {
199208
it("should return error when path is missing", async () => {
200209
const mockTask = createMockTask()

0 commit comments

Comments
 (0)