mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
fix: more vitest speedup
This commit is contained in:
@@ -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<typeof TestingLibraryReact>()
|
||||
return {
|
||||
...actual,
|
||||
waitFor: async (
|
||||
callback: Parameters<typeof actual.waitFor>[0],
|
||||
options?: Parameters<typeof actual.waitFor>[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.
|
||||
|
||||
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user