test: warm cold dynamic imports before the timed cases

Under a full coverage run on every core, a test file's first cold import
(0.6-0.8 s alone) outran the 5 s case timeout and the half-done import
failed every later case in the file: the vitest lane went red in 2 of 5
runs with no defect. A beforeAll warm-up in the 4 files of that pattern;
5 of 5 full runs green after.
This commit is contained in:
2026-10-04 20:09:58 +02:00
parent 0dfb4a984b
commit bc856ab2af
4 changed files with 38 additions and 4 deletions
@@ -4,7 +4,7 @@
// tab (bookmark, typed URL: no pin in sessionStorage) that is before BootGate pins the account, so they
// read as nobody's; they must read again on the pin. The notification store used to keep its empty,
// nobody's history, and the tab's first notice replaced the account's stored history with it.
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
const entry = (id: number, message: string) => ({
id,
@@ -24,6 +24,15 @@ const storedMessages = (account: number) =>
}[]
).map((n) => n.message);
// Warm the transform cache once (see verifyEntry.dom.test.tsx): the first cold import costs ~0.8 s
// alone and outran the 5 s case timeout under a full coverage run. Transformed code outlives
// vi.resetModules, so each case still gets fresh module instances, only faster.
beforeAll(async () => {
await import("./notifications");
await import("./hints");
await import("./api/core");
}, 60_000);
beforeEach(() => {
localStorage.clear();
sessionStorage.clear();