nextui/scripts/setup-test.ts
Junior Garcia 69aa4769c0
feat: tailwind variants upgrade (#4386)
* feat: tailwind variants upgrade

* chore: restore npmrc

* chore: adjust pkgs

* fix: versions

* fix: lock file

* chore(changeset): update package name

* chore(deps): use fixed version

* fix(test): incorrect package name

---------

Co-authored-by: աӄա <wingkwong.code@gmail.com>
2025-01-30 09:30:05 -03:00

43 lines
1.2 KiB
TypeScript

import "@testing-library/jest-dom";
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(),
}));
global.console.error = jest.fn().mockImplementation((message) => {
if (message && typeof message === "string" && message.includes("Warning: `ReactDOMTestUtils.act`")) {
return;
}
});
configure({
reactStrictMode: process.env.STRICT_MODE === "true",
});