nodeunit
nodeunit copied to clipboard
Comparison of Date objects doesn't seem to work
test.equal(new Date("3/29/2013 12:30:00 AM"), new Date("3/29/2013 12:30:00 AM"));
Hi, this is as expected. Test equal uses the '==' operator to compare the object. The objects are both of the same type but not the same object! You can try this without nodeunit: var a = new Date("3/29/2013 12:30:00 AM"); var b = new Date("3/29/2013 12:30:00 AM"); a == b; // false a === b; // false
You could do something like this to compare them: a.toString() == b.toString(); // true Or even better a.getTime() == b.getTime(); // true