// подключить в vite.config: test: { environment: "jsdom", setupFiles: ["./src/test-setup.ts"] } import "@testing-library/jest-dom/vitest"; import { cleanup } from "@testing-library/react"; import { afterEach } from "vitest"; // jsdom не умеет showModal/close у (Dialog, Confirm): открытость — атрибут open, как в браузере if (typeof HTMLDialogElement !== "undefined" && !HTMLDialogElement.prototype.showModal) { HTMLDialogElement.prototype.showModal = function showModal(this: HTMLDialogElement) { this.setAttribute("open", ""); }; HTMLDialogElement.prototype.close = function close(this: HTMLDialogElement) { this.removeAttribute("open"); }; } afterEach(() => { cleanup(); localStorage.clear(); });