perf(test): trim browser smoke and speed canvas test reload

This commit is contained in:
Peter Steinberger
2026-02-14 01:47:47 +00:00
parent db8cabedde
commit c4f550ef2a
2 changed files with 34 additions and 118 deletions

View File

@@ -264,6 +264,10 @@ export async function createCanvasHostHandler(
const rootReal = await prepareCanvasRoot(rootDir);
const liveReload = opts.liveReload !== false;
const testMode = opts.allowInTests === true;
const reloadDebounceMs = testMode ? 12 : 75;
const writeStabilityThresholdMs = testMode ? 12 : 75;
const writePollIntervalMs = testMode ? 5 : 10;
const wss = liveReload ? new WebSocketServer({ noServer: true }) : null;
const sockets = new Set<WebSocket>();
if (wss) {
@@ -293,7 +297,7 @@ export async function createCanvasHostHandler(
debounce = setTimeout(() => {
debounce = null;
broadcastReload();
}, 75);
}, reloadDebounceMs);
debounce.unref?.();
};
@@ -301,8 +305,11 @@ export async function createCanvasHostHandler(
const watcher = liveReload
? chokidar.watch(rootReal, {
ignoreInitial: true,
awaitWriteFinish: { stabilityThreshold: 75, pollInterval: 10 },
usePolling: opts.allowInTests === true,
awaitWriteFinish: {
stabilityThreshold: writeStabilityThresholdMs,
pollInterval: writePollIntervalMs,
},
usePolling: testMode,
ignored: [
/(^|[\\/])\../, // dotfiles
/(^|[\\/])node_modules([\\/]|$)/,