Incorporate destroy-circular logic. Fixes #2. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For serialized AssertionErrors, it is possible that the
actual
and
expected
properties contain circular references, causinga thrown Error when you serialize the result with JSON.stringify().
This destroys circular references on the copied Object. Replacing
them with a string (
[Circular]
).Also,
JSON.stringify(function() {})
returnsundefined
, andwill drop any functions that are attached to an object it is serializing.
This mimics the latter behavior, but if a function is passed in as the top
level argument, it returns a string (
[Function: fnName]
). Sincethe most common use for this is to transmit thrown values for logging,
it makes sense to provide this helpful String instead of
undefined
.(All this despite the fact it is a terrible idea to throw a function).
Based on:
jonpacker/destroy-circular#1
Fixes: #2