mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
a1ef3043bb
The vitest process hung after all 2132 story tests passed because leftover refetchInterval polls kept the Node.js event loop alive. Components that set per-query refetchInterval override the QueryClient default, causing HTTP requests through vite's proxy to localhost:3000 (no backend) that never resolve cleanly. Three fixes: - preview.tsx: disable all automatic refetching defaults and cancel in-flight queries on story unmount via useEffect cleanup - storybook.tsx: save/restore the original window.WebSocket in the withWebSocket decorator, clear pending timers in close() - vite.config.mts: add explicit testTimeout, hookTimeout, bail, and retry settings to the storybook vitest project Also fix 5 story files that imported from @testing-library/react instead of storybook/test.
28 lines
772 B
JavaScript
28 lines
772 B
JavaScript
// Warm vite's transform cache for storybook story files.
|
|
// Only needed on cold cache (first run after pnpm install).
|
|
import { createServer } from "vite";
|
|
import { readdirSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, "..");
|
|
|
|
const server = await createServer({
|
|
configFile: join(root, "vite.config.mts"),
|
|
root,
|
|
});
|
|
await server.listen();
|
|
|
|
const stories = readdirSync(join(root, "src"), { recursive: true })
|
|
.filter((f) => String(f).endsWith(".stories.tsx"))
|
|
.map((f) => `/src/${f}`);
|
|
|
|
await Promise.all(
|
|
stories.map((f) =>
|
|
server.environments.client.warmupRequest(f).catch(() => {}),
|
|
),
|
|
);
|
|
|
|
await server.close();
|