test(perf): reduce timer teardown overhead in cron issue regressions

This commit is contained in:
Peter Steinberger
2026-03-02 16:05:56 +00:00
parent 17c434f2f3
commit 14fbd0e6b6

View File

@@ -2,7 +2,7 @@ import crypto from "node:crypto";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import os from "node:os"; import os from "node:os";
import path from "node:path"; import path from "node:path";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { HeartbeatRunResult } from "../infra/heartbeat-wake.js"; import type { HeartbeatRunResult } from "../infra/heartbeat-wake.js";
import * as schedule from "./schedule.js"; import * as schedule from "./schedule.js";
import { CronService } from "./service.js"; import { CronService } from "./service.js";
@@ -157,17 +157,14 @@ describe("Cron issue regressions", () => {
}); });
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks();
vi.useFakeTimers(); vi.useFakeTimers();
vi.setSystemTime(new Date("2026-02-06T10:05:00.000Z")); vi.setSystemTime(new Date("2026-02-06T10:05:00.000Z"));
}); });
afterAll(async () => { afterAll(async () => {
await fs.rm(fixtureRoot, { recursive: true, force: true });
});
afterEach(() => {
vi.useRealTimers(); vi.useRealTimers();
vi.clearAllMocks(); await fs.rm(fixtureRoot, { recursive: true, force: true });
}); });
it("covers schedule updates and payload patching", async () => { it("covers schedule updates and payload patching", async () => {