react-tooltip
react-tooltip copied to clipboard
Style elements make it hard to debug failing tests
I'm using React testing library, which outputs the dom when a test fails. react-tooltip injects style elements into the dom, which make it hard to debug failing tests, especially when it results in the output getting cut off because it's so long. Ideally, I'd like some way to be able to turn off the style injection during testing.
Is there a way to turn off style element injection during jest test runs?
Running into this issue also.
same issue on our projects :-(
My workaround was to mock entirely the library with
jest.mock('react-tooltip', () => jest.fn(({ children }) => children));
but I think those repeated inline styles should be fixed regardless
@pastinepolenta it works only if you don't call the static methods of the ReactTooltip. Is there any way we can mock those as well?
I ended up not mocking the react-tooltip and set an id and uuid instead, resulting in more consistent classnames and ids, like below
<ReactTooltip id={this.state.tooltipId} uuid={this.state.tooltipId} class='c-tooltip' type='light' html />
Just make the output in the testing library longer via screen.debug(undefined, <size of output>
f.e. screen.debug(undefined, 1000000)