How to check object equality using should.js with a property value as NaN

1.9k views Asked by At

I believe this is a bug in should.js due to a special value NaN as NaN is not equal to itself.

({
    a: 1,
    c: 3,
    b: 2,
    d: NaN
}).should.eql({
    a: 1,
    c: 3,
    b: 2,
    d: NaN
});

This test case fails while it seems pretty obivious that it should pass.

Any suggestions on how to go about on this test case?

1

There are 1 answers

8
tckmn On

NaN is special in that it is not equal to itself.

> NaN == NaN
false

This is not a bug. NaN is not equal to anything. See MDN for more info.