diff --git a/spinifex/services/spinifexui/frontend/src/test/setup.ts b/spinifex/services/spinifexui/frontend/src/test/setup.ts index 560b3a75c..22617c79a 100644 --- a/spinifex/services/spinifexui/frontend/src/test/setup.ts +++ b/spinifex/services/spinifexui/frontend/src/test/setup.ts @@ -1,3 +1,4 @@ +import type * as TestingLibraryReact from "@testing-library/react" import { cleanup } from "@testing-library/react" import "@testing-library/jest-dom/vitest" import { afterEach, vi } from "vitest" @@ -8,6 +9,19 @@ afterEach(() => { cleanup() }) +// waitFor wakes on DOM mutations, otherwise it polls every 50ms. renderHook +// tests settle without touching the DOM, so each one pays a full tick. +vi.mock("@testing-library/react", async (importOriginal) => { + const actual = await importOriginal() + return { + ...actual, + waitFor: async ( + callback: Parameters[0], + options?: Parameters[1], + ) => await actual.waitFor(callback, { interval: 1, ...options }), + } +}) + // Components sign requests with the region the server reports, which the app // normally loads before rendering. Seed it through the real code path so every // component test has one without stubbing fetch itself. diff --git a/spinifex/services/spinifexui/frontend/vite.config.ts b/spinifex/services/spinifexui/frontend/vite.config.ts index 0537e49e3..e38a04b5f 100644 --- a/spinifex/services/spinifexui/frontend/vite.config.ts +++ b/spinifex/services/spinifexui/frontend/vite.config.ts @@ -42,6 +42,7 @@ export default defineConfig(({ mode }) => ({ environment: "happy-dom", setupFiles: "./src/test/setup.ts", clearMocks: true, + pool: "threads", coverage: { include: ["src/**/*.{ts,tsx}"], exclude: [