-
-
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-format: Support HTMLCollection and NodeList in DOMCollection plugin #7125
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7125 +/- ##
======================================
Coverage 66.6% 66.6%
======================================
Files 253 253
Lines 10629 10629
Branches 3 4 +1
======================================
Hits 7079 7079
Misses 3549 3549
Partials 1 1
Continue to review full report at Codecov.
|
|
||
// Omitted a test for form.elements because constructor.name | ||
// is HTMLCollection in jsdom version 11 | ||
// might become HTMLFormControlsCollectio in jsdom 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsdom 12 is released, and while we won't upgrade for some time, maybe we can normalize the name to HTMLFormControlsCollection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified outside Jest that form.elements
still HTMLCollection
class in jsdom@12.2.0 so added the test. Wrote a comment so that we will know to update the criterion if it ever changes.
'}' | ||
: '[' + | ||
printListItems( | ||
Array.prototype.slice.call(collection), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.from
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will leave the compiling to Babel :)
Documenting decision to serialize in list item format:
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes #7121
Problem: When
pretty-format
serializes ajsdom
object instance for which no plugin matches, it takes a “stupid amount of time” on the property with keySymbol(impl)
and then fails.Solution: Support HTML collection classes to write assertions for received values:
childNodes
,children
,elements
,options
getElementsByTagName
and so onquerySelectorAll
Also added support for
config.min
option to omit class name.Be aware that class names can be moving targets even in browsers:
form.elements
returnedHTMLFormControlsCollection
fieldset.elements
returnedHTMLCollection
despite the claim at Mozilla Developer Network
So there is some risk for test writers that snapshots might need to be updated at major version upgrades of
jsdom
package.Test plan
config.min
optionconfig.maxDepth
option