-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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-print not handling web components properly #10226
Comments
Custom elements must be registered with a hyphen in the name so I think From https://html.spec.whatwg.org/multipage/custom-elements.html:
|
Another viable option would also be to just check if element is an instance of |
I'm down with treating them the same as any built-in nodes. /cc @pedrottimark |
Here #10237 |
Released in 26.2.0 |
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. |
Actually I describe it here:
testing-library/react-testing-library#679 (comment)
Basically there is a problem with serializing JSDOM structure by pretty-print in case there is a web component used in rendered tree and it is registered as custom element. Due to the regex used in the code below:
https://github.com/facebook/jest/blob/08f00e94f7fd8a4fc0c1eb3e01fe8d05b43538be/packages/pretty-format/src/plugins/DOMElement.ts#L24
the web component is not actually treated as DOMElement and pretty-print fallbacks to just printing the element in key/value manner which unfortunately breaks the app at some point if there is a lot of web components used due to too long string being generated. Potential solutions I see would be to:
or even to not check it at all since custom element's
constructor.name
can be pretty much anythingcreate a new plugin which would somehow handle this
just leave it as it is and force users of this package to create their own plugins
Honestly I think that web components should be treated just like a built-in DOM elements so changes to the
testNode
method in DOMElement plugin would need to be made, but I'd gladly discuss this :)The text was updated successfully, but these errors were encountered: