Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uppretty-format: Support HTMLCollection and NodeList in DOMCollection plugin #7125
Conversation
facebook-github-bot
added
the
cla signed
label
Oct 8, 2018
pedrottimark
requested a review
from
SimenB
Oct 8, 2018
This comment has been minimized.
This comment has been minimized.
codecov-io
commented
Oct 8, 2018
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.
|
SimenB
reviewed
Oct 9, 2018
|
||
// Omitted a test for form.elements because constructor.name | ||
// is HTMLCollection in jsdom version 11 | ||
// might become HTMLFormControlsCollectio in jsdom 12 |
This comment has been minimized.
This comment has been minimized.
SimenB
Oct 9, 2018
Collaborator
jsdom 12 is released, and while we won't upgrade for some time, maybe we can normalize the name to HTMLFormControlsCollection
?
This comment has been minimized.
This comment has been minimized.
pedrottimark
Oct 9, 2018
Author
Collaborator
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.
SimenB
reviewed
Oct 9, 2018
'}' | ||
: '[' + | ||
printListItems( | ||
Array.prototype.slice.call(collection), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Documenting decision to serialize in list item format:
|
pedrottimark commentedOct 8, 2018
•
edited
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