mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import "@testing-library/jest-dom/extend-expect";
|
|
import { configure } from "@testing-library/react";
|
|
|
|
const {getComputedStyle} = window;
|
|
window.getComputedStyle = (elt) => getComputedStyle(elt);
|
|
|
|
if (typeof window.matchMedia !== "function") {
|
|
Object.defineProperty(window, "matchMedia", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true,
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(), // Deprecated
|
|
removeListener: jest.fn(), // Deprecated
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
});
|
|
}
|
|
|
|
// Workaround https://github.com/jsdom/jsdom/issues/2524#issuecomment-897707183
|
|
global.TextEncoder = require("util").TextEncoder;
|
|
|
|
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
observe: jest.fn(),
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
}));
|
|
|
|
configure({
|
|
reactStrictMode: process.env.STRICT_MODE === "true",
|
|
});
|