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

Pretty-printing jsdom objects is way too verbose #2146

Closed
gaearon opened this issue Nov 21, 2016 · 6 comments
Closed

Pretty-printing jsdom objects is way too verbose #2146

gaearon opened this issue Nov 21, 2016 · 6 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Nov 21, 2016

This is what I see with a single failing expectation:

gif

This is because jsdom has its implementation under a Symbol() key, and a single jsdom element brings the whole jsdom with it.

Can we fix it by adding some sort of pretty-printing for jsdom? I know that's what @yaycmyk attempted in jamiebuilds/pretty-format#47 but it received a comment:

I also don't think HTML printing should be a default. I don't actually want to pretty-print HTML elements in Jest like this.

If we really want to do this, the right way is to build a plugin and then use instanceof checks with the objects coming from jsdom.

Shall we do this them?

Another way to fix this specific issue would be to skip Symbol() keys since they're intentionally "private". The downside would be that comparing two objects with different values under Symbol keys would presumably miss those differences. We could maybe only print Symbol() keys if we know the difference is inside of them but skip them otherwise.

Yet another way to fix it would be to limit nesting when printing difference to something like 3. I think it's what Node does in console.log but I might be wrong.

@thymikee
Copy link
Collaborator

@yaycmyk are you interested in making such plugin for pretty-format?

@quantizor
Copy link
Contributor

quantizor commented Jan 30, 2017 via email

@thymikee
Copy link
Collaborator

Thanks! Marking this as a Good First Task then, since majority of the work is done by you.

@mute
Copy link
Contributor

mute commented Mar 16, 2017

I'd like to pick this up (assuming it's still valid/desired).

@cpojer
Copy link
Member

cpojer commented Mar 16, 2017

Go for it! Check out the pretty-format package in the Jest repo and how the plugin system works.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants