44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
import { cleanup } from "@testing-library/react";
|
|
import { vi } from "vitest";
|
|
import "./i18n.test";
|
|
|
|
// Cleanup after each test case
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
// Mock ResizeObserver
|
|
global.ResizeObserver = class ResizeObserver {
|
|
observe() {
|
|
// Mock implementation
|
|
}
|
|
unobserve() {
|
|
// Mock implementation
|
|
}
|
|
disconnect() {
|
|
// Mock implementation
|
|
}
|
|
};
|
|
|
|
// Mock scroll APIs for DOM-oriented tests without breaking node-environment suites.
|
|
if (typeof Element !== "undefined") {
|
|
Element.prototype.scrollIntoView = vi.fn();
|
|
Element.prototype.scrollTo = vi.fn();
|
|
}
|
|
|
|
if (typeof window !== "undefined") {
|
|
Object.defineProperty(window, "matchMedia", {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(), // deprecated
|
|
removeListener: vi.fn(), // deprecated
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|
|
}
|