Skip to content
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

fix(diff): retain undefined and NaN in output #42

Merged
merged 5 commits into from
Aug 8, 2020
Merged

Conversation

lukeed
Copy link
Owner

@lukeed lukeed commented Aug 8, 2020

By default, JSON.stringify hides undefined and NaN values.

This can be super annoying when your assertion fails correctly, but doesn't show you the reason(s) why. Take these comparisons for example:

You can see that direct, simple comparisons (via assert.is) are fine. But any instances within complex values (object, arrays) were lost. AKA, the { foo: NaN } was printed as { foo: null } -- hence grey text. We see this again with the last assertion with { foo: null } ... and then { foo: undefined } is hidden entirely, leaving an empty Expected: block.

After these changes, undefined and NaN are printed in the diff'ing output so that we have true data representations~!

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2020

Codecov Report

Merging #42 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #42   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files           3        3           
  Lines         302      302           
=======================================
  Hits          272      272           
  Misses         30       30           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18ada58...32ab597. Read the comment docs.

@lukeed lukeed merged commit 4853b49 into master Aug 8, 2020
@lukeed lukeed deleted the fix/void-nan-json branch August 8, 2020 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants