perf(test): reduce setup overhead; isolate sharp-heavy suites

This commit is contained in:
Peter Steinberger
2026-02-14 03:29:55 +00:00
parent 2d4d32cb2d
commit 38a157ff23
2 changed files with 12 additions and 2 deletions

View File

@@ -15,7 +15,10 @@ const unitIsolatedFiles = [
"src/auto-reply/tool-meta.test.ts",
"src/auto-reply/envelope.test.ts",
"src/commands/auth-choice.test.ts",
"src/media/store.test.ts",
"src/media/store.header-ext.test.ts",
"src/web/media.test.ts",
"src/web/auto-reply.web-auto-reply.falls-back-text-media-send-fails.test.ts",
"src/browser/server.covers-additional-endpoint-branches.test.ts",
"src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts",
"src/browser/server.agent-contract-snapshot-endpoints.test.ts",

View File

@@ -163,11 +163,18 @@ const createDefaultRegistry = () =>
},
]);
// Creating a fresh registry before every single test was measurable overhead.
// The registry is treated as immutable by production code; tests that need a
// custom registry set it explicitly.
const DEFAULT_PLUGIN_REGISTRY = createDefaultRegistry();
beforeEach(() => {
setActivePluginRegistry(createDefaultRegistry());
setActivePluginRegistry(DEFAULT_PLUGIN_REGISTRY);
});
afterEach(() => {
// Guard against leaked fake timers across test files/workers.
vi.useRealTimers();
if (vi.isFakeTimers()) {
vi.useRealTimers();
}
});