import "@testing-library/jest-dom/vitest" import { cleanup } from "@testing-library/react" import { afterEach, vi } from "vitest" // Testing Library only auto-registers its cleanup when vitest runs with // `globals: true`. This config does not, so unmount between tests explicitly — // otherwise every render stacks up in document.body and singular queries like // getByRole start failing on the second open surface. afterEach(() => { cleanup() }) // jsdom does not implement window.matchMedia — stub it for tests that use // useTableState (which calls useSyncExternalStore with a matchMedia listener) Object.defineProperty(window, "matchMedia", { writable: true, value: (query: string) => ({ matches: false, media: query, onchange: null, addListener: vi.fn(), removeListener: vi.fn(), addEventListener: vi.fn(), removeEventListener: vi.fn(), dispatchEvent: vi.fn(), }), }) // jsdom does not implement ResizeObserver — stub it for components that use // Radix UI primitives (Sheet, Tooltip, etc.) which call it internally. globalThis.ResizeObserver = class { observe = vi.fn() unobserve = vi.fn() disconnect = vi.fn() }