-
-
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
expect: Compare DOM nodes even if there are multiple Node classes #8064
expect: Compare DOM nodes even if there are multiple Node classes #8064
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8064 +/- ##
==========================================
+ Coverage 62.36% 62.37% +0.01%
==========================================
Files 262 262
Lines 10312 10313 +1
Branches 2491 2491
==========================================
+ Hits 6431 6433 +2
Misses 3307 3307
+ Partials 574 573 -1
Continue to review full report at Codecov.
|
Interesting, I didn't think of cases where nodes may have different base classes and the tests obviously also didn't check for that 😄 - at least now that's part of the official API documented by the test suite. |
The new tests make sure that Jest works for ordinary DOM and doesn’t regress for your use case. Although we confirmed the breaking case in local tests, it seemed too brittle for Jest repo. |
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
The solution in #7995 was an unintended breaking change for tests that compare DOM nodes which are not
instanceof
theNode
class that in the global scope:JSDOM.fragment
returns fragment which has different base class thanNode
class from--env=jsdom
optioniframe
elementReplace
isDomNode
function with a possibility that we discussed in #7791 (comment)/cc @mfeineis
Although this change makes it possible to compare two nodes which have the same base class, it wasn’t and still isn’t possible to compare two nodes which have different base classes because the
isEqualNode
method throwsTypeError: Failed to execute 'isEqualNode' on 'Node': parameter 1 is not of type 'Node'.
Test plan
Existing tests pass
Added
toEqual-dom.test.js
file as spec for:isEqualNode
methodisEqualNode
method to prevent regression Expect dies with "ReferenceError: Element is not defined" in "node" test environment #7786I didn’t add test of multiple
Node
classes because it might break in futurejsdom
versions