From 876d729f224456d85cc696c742f280b7e277b8cd Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:58:03 -0700 Subject: [PATCH] fix(test): stop a leaked real timer from failing the updater scheduling test The suite mixes real-timer tests with fake-timer ones against a shared autoUpdater mock. resetUpdaterMocks() does vi.resetModules() + useRealTimers(), neither of which cancels a real timer already armed by the module instance it orphans. The stale instance's 1s silent-settle timer then fired inside a later fake-timer test and re-armed a 24h automatic check against the faked clock, producing a phantom checkForUpdates at fake offset 86400s and failing 'reschedules the next automatic check 24 hours after finding an available update' with 'expected 1 time, got 2'. Installing fake timers in beforeEach makes every timer this file arms discardable: the next reset's useRealTimers() uninstalls the clock and drops them. The assertion is unchanged. --- src/main/updater.startup-scheduling.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/updater.startup-scheduling.test.ts b/src/main/updater.startup-scheduling.test.ts index 06a1ea041be..a58fa0af049 100644 --- a/src/main/updater.startup-scheduling.test.ts +++ b/src/main/updater.startup-scheduling.test.ts @@ -27,7 +27,12 @@ vi.mock('./local-builds/local-build-feed-server', () => moduleFactories.localBui describe('updater', () => { beforeEach(() => { + // Why: resetUpdaterMocks() uninstalls fake timers, which discards every timer the previous test + // armed; re-faking here keeps this test's timers discardable too. On real timers a stale + // `vi.resetModules()`-orphaned updater instance survived to re-arm its 24h check inside a later + // fake-timer test, adding a phantom checkForUpdates at fake offset 24h. resetUpdaterMocks() + vi.useFakeTimers() }) it('does not load or configure electron-updater during dev setup', async () => {