-
Notifications
You must be signed in to change notification settings - Fork 142
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
🐛 Revert Errors serialization behavior #2197
🐛 Revert Errors serialization behavior #2197
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2197 +/- ##
==========================================
+ Coverage 93.81% 93.90% +0.08%
==========================================
Files 201 201
Lines 6082 6088 +6
Branches 1347 1349 +2
==========================================
+ Hits 5706 5717 +11
+ Misses 376 371 -5
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
6363cfa
to
1e9cbe7
Compare
1e9cbe7
to
859cdee
Compare
/to-staging |
🚂 Branch Integration commit 859cdee will soon be integrated into staging-18. This build is going to start soon! (estimated merge in less than 0s) you can cancel this operation by commenting your pull request with |
🚂 Branch Integration commit 859cdee has been merged into staging-18 |
// IE11 adds a description field | ||
// Safari IOS12 adds parts of the stack | ||
const error = new Error('My Error') | ||
expect(JSON.stringify(sanitize(error))).toEqual(JSON.stringify(error)) |
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.
🥜 nitpick: did you try using { ...error }
or Object.assign({}, error)
instead of JSON.stringify
? It should yield better message when the assertion fails
expect(JSON.stringify(sanitize(error))).toEqual(JSON.stringify(error)) | |
expect(sanitize(error)).toEqual({ ...error }) |
Motivation
Change of behavior when serializing errors:
#2195
Previously, an errror was serialized as an empty object
{}
. However, additional properties (added manually or from a custom error) were serialized:Errors fall in the catch-all within the sanitize process, resulting in :
Changes
Specific handler for
instanceof
ErrorSerialize additional properties from errors
=> [Error] reverts back to
{}
(empty object) for errors without additional properties.Testing
I have gone over the contributing documentation.