fleet/frontend/test/test-setup.ts
Gabriel Hernandez c854509821
Suppress unneeded react tooltip test warning and update lib to latest version (#30584)
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 -->
2025-07-07 15:33:35 +01:00

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);
};
});