mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
This suppresses an unneeded react-tooltip opacity warning when the tests are run. The code is correct when assigning the opacity and this may just be an issue with react-tooltip and jsdom not working nicely together. This was causing to much noise in the console. We've also updated react-tooltip 5 to the latest version <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated the react-tooltip-5 dependency to a newer version. * Suppressed specific harmless warnings related to react-tooltip during test runs for cleaner test output. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
31 lines
967 B
TypeScript
31 lines
967 B
TypeScript
import "@testing-library/jest-dom";
|
|
import mockServer from "./mock-server";
|
|
|
|
// Needed for testing react-tooltip-5
|
|
window.CSS.supports = jest.fn();
|
|
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
observe: jest.fn(),
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
}));
|
|
|
|
// Mock server setup
|
|
beforeAll(() => mockServer.listen());
|
|
afterEach(() => mockServer.resetHandlers());
|
|
afterAll(() => mockServer.close());
|
|
|
|
// suppress the opacity console warnings for react-tooltip. The code for assigning the
|
|
// opacity is correct but there is still an unnecessary warning in the console when
|
|
// the jest tests are run. This may be react-tooltip and JSdom not playing well together.
|
|
beforeAll(() => {
|
|
const originalConsoleWarning = console.warn;
|
|
console.warn = (...args) => {
|
|
if (
|
|
args[0]?.includes("[react-tooltip]") &&
|
|
args[0]?.includes("is not a valid `opacity`")
|
|
) {
|
|
return;
|
|
}
|
|
originalConsoleWarning(...args);
|
|
};
|
|
});
|