react-components
react-components copied to clipboard
Tooltip tests occasionally fail
Tooltips tests fail from time to time. It's hard to reproduce as it doesn't happen in deterministic way.
The error when it happens is:
● Tooltip › updates the tooltip to fit on the screen
expect(element).toHaveClass("p-tooltip--btm-left")
Expected the element to have class:
p-tooltip--btm-left
Received:
p-tooltip--right is-detached
153 | await userEvent.hover(screen.getByRole("button", { name: "Child" }));
154 |
> 155 | expect(screen.getByTestId("tooltip-portal")).toHaveClass(
| ^
156 | "p-tooltip--btm-left"
157 | );
158 | expect(screen.getByTestId("tooltip-portal")).toHaveClass("is-detached");
at src/components/Tooltip/Tooltip.test.tsx:155:50
at fulfilled (src/components/Tooltip/Tooltip.test.tsx:28:58)
There seems to be some bug or race condition either in the Tooltip component or its test suite.