import "@testing-library/jest-dom/vitest"; import { cleanup } from "@testing-library/react"; import { afterEach } from "vitest"; afterEach(() => cleanup()); // jsdom 缺口 polyfill(spec S2):radix 原语在 jsdom 下的已知缺失,一次配好全体组件测试共用。 class ResizeObserverStub { observe() {} unobserve() {} disconnect() {} } globalThis.ResizeObserver ??= ResizeObserverStub as unknown as typeof ResizeObserver; Element.prototype.scrollIntoView ??= function scrollIntoView() {}; // radix 的焦点/拖拽逻辑会探测 pointer capture API,jsdom 未实现 Element.prototype.hasPointerCapture ??= (() => false) as never; Element.prototype.setPointerCapture ??= (() => {}) as never; Element.prototype.releasePointerCapture ??= (() => {}) as never;