perf(test): reduce hot-suite setup and duplicate test work

This commit is contained in:
Peter Steinberger
2026-02-13 23:30:35 +00:00
parent ab4a08a82a
commit e794ef0478
5 changed files with 65 additions and 239 deletions

View File

@@ -15,22 +15,22 @@ describe("waitForTransportReady", () => {
let attempts = 0;
const readyPromise = waitForTransportReady({
label: "test transport",
timeoutMs: 500,
logAfterMs: 120,
logIntervalMs: 100,
pollIntervalMs: 80,
timeoutMs: 220,
logAfterMs: 60,
logIntervalMs: 1_000,
pollIntervalMs: 50,
runtime,
check: async () => {
attempts += 1;
if (attempts > 4) {
if (attempts > 2) {
return { ok: true };
}
return { ok: false, error: "not ready" };
},
});
for (let i = 0; i < 5; i += 1) {
await vi.advanceTimersByTimeAsync(80);
for (let i = 0; i < 3; i += 1) {
await vi.advanceTimersByTimeAsync(50);
}
await readyPromise;
@@ -41,14 +41,14 @@ describe("waitForTransportReady", () => {
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
const waitPromise = waitForTransportReady({
label: "test transport",
timeoutMs: 200,
timeoutMs: 110,
logAfterMs: 0,
logIntervalMs: 100,
logIntervalMs: 1_000,
pollIntervalMs: 50,
runtime,
check: async () => ({ ok: false, error: "still down" }),
});
await vi.advanceTimersByTimeAsync(250);
await vi.advanceTimersByTimeAsync(200);
await expect(waitPromise).rejects.toThrow("test transport not ready");
expect(runtime.error).toHaveBeenCalled();
});