Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to suppress logging full DOM #360

Closed
benmonro opened this issue Sep 24, 2019 · 8 comments · Fixed by #452
Closed

Ability to suppress logging full DOM #360

benmonro opened this issue Sep 24, 2019 · 8 comments · Fixed by #452
Labels
enhancement New feature or request help wanted Extra attention is needed released

Comments

@benmonro
Copy link
Member

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:

@eps1lon
Copy link
Member

eps1lon commented Sep 24, 2019

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.

@herecydev
Copy link

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?

@kentcdodds
Copy link
Member

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.

@kentcdodds
Copy link
Member

Whoops, didn't mean to close this.

@kentcdodds kentcdodds reopened this Jan 21, 2020
@kentcdodds kentcdodds added enhancement New feature or request help wanted Extra attention is needed labels Jan 21, 2020
aw-davidson pushed a commit to aw-davidson/dom-testing-library that referenced this issue Feb 12, 2020
@Volox
Copy link

Volox commented Feb 14, 2020

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

aw-davidson pushed a commit to aw-davidson/dom-testing-library that referenced this issue Feb 17, 2020
aw-davidson pushed a commit to aw-davidson/dom-testing-library that referenced this issue Mar 3, 2020
aw-davidson pushed a commit to aw-davidson/dom-testing-library that referenced this issue Mar 4, 2020
@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 6.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@g-wozniak
Copy link

Is there any alternative for this to be available for @testing-library/webdriverio ?
Apparently configure() does not allow neither for:

  • showLogOnFail to be passed (does not exist in the context at all)
  • showOriginalStackTrace is not a valid property (regardless being in the Config type)
  • throwSuggestions does not make any difference to this...

@MatanBobi
Copy link
Member

Hi @g-wozniak,
you can go ahead and use getElementError which is a function that runs everytime a getBy* query fails:
https://github.com/testing-library/dom-testing-library/blob/main/src/config.ts#L33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants