react-tooltip icon indicating copy to clipboard operation
react-tooltip copied to clipboard

Style elements make it hard to debug failing tests

Open narthur opened this issue 4 years ago • 5 comments

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?

narthur avatar Jan 06 '21 20:01 narthur

Running into this issue also.

aknee-dmi avatar Jan 19 '21 19:01 aknee-dmi

same issue on our projects :-(

artem-deikun-katapult avatar Mar 05 '21 13:03 artem-deikun-katapult

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 avatar Apr 21 '21 12:04 pastinepolenta

@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?

stefann01 avatar Apr 18 '22 13:04 stefann01

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 />

Elegant-Bird avatar Jul 12 '22 18:07 Elegant-Bird

Just make the output in the testing library longer via screen.debug(undefined, <size of output> f.e. screen.debug(undefined, 1000000)

GLObus303 avatar Dec 10 '23 13:12 GLObus303