Dom-testing-library: Stop HTML DOM output on test error

Created on 29 Sep 2020  路  4Comments  路  Source: testing-library/dom-testing-library

Describe the feature you'd like:

Please can we have a way to stop outputting the HTML of the DOM when there's an error? I can't think of a single time I've found this helpful, and outputting 9000 characters for every failed test means I can't read the output in the console window in any sensible way.

This one issue has put off work mates from wanting to use this library! And the library is _super awesome_!

I'm not sure if testing-library can read my Jasmine conf? But it'd ideally not be an environment variable, because its tricky to get the Karma runner to read them :(

Describe alternatives you've considered:

I've tried setting the PrettyDOM limit to 0 using the env variable - but a) that means I can't then manually run debug(el) to see some actually useful HTML and b) it doesn't work with Karma (I'm using testing-library with Karma in an Angular project, which I realise is pretty unusual - but I love it too much!!).

Most helpful comment

Thats awesome! I hadn't seen that, thank you @wyze !

And I can get rid of the callstack, too, with error.callstack = null; Amazing 馃憤

All 4 comments

Looks like you may be able to set the getElementError config option to something else. https://github.com/testing-library/dom-testing-library/blob/01e243b4d25274ae8f8b5e2c6864abc27184df5b/src/config.js#L26-L33

Thats awesome! I hadn't seen that, thank you @wyze !

And I can get rid of the callstack, too, with error.callstack = null; Amazing 馃憤

@wyze do let me know if you want the credit over on Stack Overflow (https://stackoverflow.com/questions/64045789) - I'll use your answer there for now 馃憤

Didn't know it was also on SO, so I answered there as well. Thanks @IanGrainger!

Was this page helpful?
0 / 5 - 0 ratings