Dom-testing-library: Ability to suppress logging full DOM

Created on 24 Sep 2019  路  6Comments  路  Source: testing-library/dom-testing-library

Describe the feature you'd like:


Looking for a way to disable the full DOM logging. In RTL it makes sense to see the rendered output when a query fails, as it's usually pretty small. But when using Testcafe testing library, its dumping the entire DOM and pretty much takes over my entire terminal. Would be nice to have a flag you can set in the configure() function that allows you to suppress the full DOM logging.

Suggested implementation:

configure({showLogOnFail:false}) (default's to current behavior, true)

Describe alternatives you've considered:

I noticed an environment variable that lets you control the size, but testcafe runs the tests in-browser so i don't think that will work.

Teachability, Documentation, Adoption, Migration Strategy:

enhancement help wanted released

Most helpful comment

I was looking for the same feature and stumbled upon the following in the doc:
https://testing-library.com/docs/dom-testing-library/api-helpers#debugging

Basically by setting the env DEBUG_PRINT_LIMIT to something it will cap the output.

Not sure if it helps :)

Also I agree with @eps1lon a finer grained control can be a lot useful...

All 6 comments

I would like to use the opportunity and make the verbosity a bit more granular. Most of the time it isn't necessary to log the full dom of the available roles. A shallow log for roles + their top level element with attributes is usually enough.

On a similar note, it would be nice to trim out react's internal comments like <!-- /react-text --><!-- react-text: 28 -->

They are important for react to track it's nodes but not important for seeing what's rendered (at least in most cases). This can be easily achieved using ReactDOMserver, but that won't technically be the window.document, so perhaps removing comments from prettyDOM might be better?

I'm fine with changing the behavior here a little bit. Anyone who feels strongly about this can feel free to open a PR with some suggested APIs for this and we can make it happen (hopefully without breaking changes).

@herecydev, I'm not sure we can reliably remove those commends without causing more confusion, but maybe we could expose an API that inverts control to you so you can do that yourself.

Whoops, didn't mean to close this.

I was looking for the same feature and stumbled upon the following in the doc:
https://testing-library.com/docs/dom-testing-library/api-helpers#debugging

Basically by setting the env DEBUG_PRINT_LIMIT to something it will cap the output.

Not sure if it helps :)

Also I agree with @eps1lon a finer grained control can be a lot useful...

:tada: This issue has been resolved in version 6.13.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ysgk picture ysgk  路  3Comments

PaulInglis picture PaulInglis  路  3Comments

icfantv picture icfantv  路  4Comments

nicolasschabram picture nicolasschabram  路  3Comments

NiGhTTraX picture NiGhTTraX  路  3Comments