-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update jest-utils.ts #2990
Update jest-utils.ts #2990
Conversation
don't do property access to check if something isDomNode
packages/expect/src/jest-utils.ts
Outdated
@@ -135,10 +135,6 @@ function eq( | |||
if (typeof a !== 'object' || typeof b !== 'object') | |||
return false | |||
|
|||
// Use DOM3 method isEqualNode (IE>=9) | |||
if (isDomNode(a) && isDomNode(b)) |
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.
We can't just remove this because someone wants to.
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.
@sheremet-va I agree, but wouldn't this be something that should enhance functionality? e.g. if you're using the JSDOM adapter? if you're not writing tests for non-browser APIs, why should it exist?
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.
There is no JSDOM adapter for equality
. If you are afraid of the Proxy usage here we can change it in a few other ways:
- Check that global
Element
exists and checkinstanceof
on the value. - Instead of direct access
obj.nodeType
use'nodeType' in obj && obj.nodeType
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.
@sheremet-va that's a great suggestion :) Updated.
@sheremet-va friendly ping |
don't do property access to check if something isDomNode
this call is breaking the usage of proxy objects in tests, e.g. if I want to make sure that the object I'm testing is only ever accessing keys it defined.
where fromPartial looks like this: