mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 01:52:04 +00:00
test: reset leaked cron fake timers
This commit is contained in:
@@ -73,6 +73,10 @@ export function installCronTestHooks(options: {
|
||||
}) {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
// Shared unit-thread workers run with isolate disabled, so leaked cron
|
||||
// timers from a previous file can still sit in the fake-timer queue.
|
||||
// Clear them before advancing time in the next test file.
|
||||
vi.clearAllTimers();
|
||||
vi.setSystemTime(new Date(options.baseTimeIso ?? "2025-12-13T00:00:00.000Z"));
|
||||
options.logger.debug.mockClear();
|
||||
options.logger.info.mockClear();
|
||||
@@ -81,6 +85,7 @@ export function installCronTestHooks(options: {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllTimers();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user