-
-
Notifications
You must be signed in to change notification settings - Fork 772
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
Prevent matcher failures from printing large deeply nested objects #2306
Comments
Thank you for taking the time to explain the issue with this level of detail. I have experienced the same problem before, in my case with http request objects on node. It's not a trivial change though. I think we'd have to create a deep copy of the Should you be interested in implementing this, I'm here to help. Otherwise I'll get to it eventually. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is your feature request related to a problem? Please describe.
We frequently use matchers to assert that a particular set of fields on a POJO matches certain values. For example:
This comes up most frequently when making assertions about how a function was invoked when the args are combined into a single POJO (which is a somewhat common pattern).
However, if any of the values is a very large, deeply nested object, then a matcher failure will attempt to print the entire object deeply, regardless of whether the match failure was present in that object. When the object is large enough, this can take long enough that it's unclear what's going on and what you've done wrong.
Describe the solution you'd like
The matcher should make an attempt to give feedback only on the parts of the object that were mismatched. For example:
should print something like
Describe alternatives you've considered
I've discovered that the problem can be avoided by adding a
toString
method to the large deeply nested object. This helps, but is a losing battle; I can't anticipate all the large objects out there that might cause this problem.Additional context
I'm using Sinon 9.2.0.
Example repro:
The text was updated successfully, but these errors were encountered: