Is it possible to remove/disable the html output that always spits out when running RTL tests?
My finger is getting sore from scrolling past the HTML output to find the start of the stack trace.
After scrolling and scrolling this is where I want to get to:
I still want to have the stack trace shown. That is more important to me than the HTML snippet. Unfortunately none of the approaches I have looked at worked because I still want to see the stack trace.
2
Answers
The issue arises from RTL’s screen.debug() or prettyDOM calls that output the HTML structure of the components being tested
I think You can mock the prettyDOM function or screen.debug() method to prevent them from outputting the HTML while preserving the stack trace.
This might help.
You can use the configure method of testing library to change the error message thrown when get or find queries fail, as indicated in this issue.
I’m assuming you are using jest. If that’s the case, you can add to your current jest setup a file that runs after the jest environment has been set:
And it that file you can change the
getElementError
to something like: