moll / js-must

An assertion library for JavaScript and Node.js with a friendly BDD syntax (awesome.must.be.true()). It ships with many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good stuff and well tested.
Other
336 stars 35 forks source link

mismatch description displays NaN as null when comparing objects #56

Closed UrsMetz closed 7 years ago

UrsMetz commented 7 years ago

When comparing objects using eql and the actual object has a property that is NaN the diff of the failed assertion is misleading: the following assertion

const expect = require("must")

expect({a: NaN}).to.eql({a: 1})

results in this message:

AssertionError: {"a":null} must be equivalent to {"a":1}

The root cause is that json-stringify-safe converts NaN to null.

moll commented 7 years ago

You're absolutely right! Thanks for bringing this to my attention again! I fixed that and released v0.13.3. Please give it a try and let me know if it wasn't what you were expecting! I'll close this until again. :)

UrsMetz commented 7 years ago

@moll just gave it a try and it works as expected, thanks for the fast fix and release! :-)