-
-
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
[toMatchObject] Check different Error objects (#3864) #3866
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Makes sense, thanks for your contribution! Let's wait for CI to pass. |
Codecov Report
@@ Coverage Diff @@
## master #3866 +/- ##
==========================================
+ Coverage 57.63% 57.65% +0.01%
==========================================
Files 194 194
Lines 6782 6782
Branches 6 6
==========================================
+ Hits 3909 3910 +1
+ Misses 2870 2869 -1
Partials 3 3
Continue to review full report at Codecov.
|
@anilreddykatta let's discuss it here. I'm good with Errors being compared by message. |
Please rebase. |
@nathanforce can you rebase this PR so I can merge it? :) |
287b9f3
to
b285c13
Compare
I also investigated this issue and my fix was slightly different. I updated the This way we don't have to rely on the ordering of the code of It turns out that running
And an error is an
Therefore I updated the code for this matcher: const isObjectWithKeys = a =>
a !== null &&
typeof a === 'object' &&
Object.keys(a).length && // <------ new code
!(a instanceof Array) &&
!(a instanceof Date);
const subsetEquality = (object, subset) => {
if (!isObjectWithKeys(object) || !isObjectWithKeys(subset)) {
return undefined;
}
return Object.keys(subset).every(
key =>
hasOwnProperty(object, key) &&
equals(object[key], subset[key], [iterableEquality, subsetEquality]),
);
}; Additionally, it seems like this code could be moved to the WDYT? |
@jseminck I see your point. Do you have those changes already made? |
I have them in a local branch. But maybe it can be a separate PR after this is merged (just as a part of some code cleanup)? |
@jseminck I am closing this in favor of your changes. Could you open a PR against the issue? |
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 #3859. Similar to PR #3864 but fixes the issue further up the chain.
Test Plan
yarn jest
after adding tomatchers-test.js