From 282e1c40a98e5deecd2e5783526fc8c5542a605b Mon Sep 17 00:00:00 2001 From: Levy Tate <78818969+iLevyTate@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:52:25 -0500 Subject: [PATCH] test(vision): mock available memory so macOS runs do not count the sysctl probe as a spawn The real ModelMemoryManager now reads available memory through the shared systemMemory reader, which on darwin starts a background `sysctl kern.memorystatus_level` spawn. The memory-budget test asserts the vision runtime never spawned, so on the macOS runner it counted that probe. Reproduced on Windows by running the suite with process.platform set to darwin (1 failed); with the mock it passes there and natively. --- test/VisionService.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/VisionService.test.js b/test/VisionService.test.js index f41ccd6..61e0cf4 100644 --- a/test/VisionService.test.js +++ b/test/VisionService.test.js @@ -64,6 +64,14 @@ jest.mock('child_process', () => { }; }); +// On macOS the real ModelMemoryManager reads available memory through a +// background `sysctl` spawn, which the spawn mock above would count as the +// vision runtime starting. Read os.freemem() on every platform instead. +jest.mock('../src/main/utils/systemMemory', () => ({ + getAvailableMemoryBytes: jest.fn(async () => require('os').freemem()), + peekAvailableMemoryBytes: jest.fn(() => require('os').freemem()) +})); + // Mock adm-zip and tar (not needed in unit tests) jest.mock('adm-zip', () => jest.fn()); jest.mock('tar', () => ({ x: jest.fn() }));