I have this code
var assert = require('assert');
describe('date', function() {
it('deep equal', function() {
assert.deepEqual({date: ''}, {date:new Date()});
});
});
when I run the test with mocha I get this
AssertionError: { date: '' } deepEqual { date: 2017-03-08T21:58:45.767Z }
+ expected - actual
{
- "date": ""
+ "date": [Date: 2017-03-08T21:58:45.767Z]
}
at Context.<anonymous> (test/test_date.js:5:12)
Why the date generated in the deepEqual have this format [Date: 2017-03-08T21:58:45.767Z] and not this format 2017-03-08T21:58:45.767Z ?
Why the date generated is between the brackets [Date: ...] ?
It seems to me that this is the way your testing suite shows you that the object is an instance of the
Dateclass. You would not get this information if it were simply2017-03-08T21:58:45.767Z, and would possibly be harder to debug in a more complex scenario.In the first line,
It's showing the
toISOString()representation, but this could be misleading because the value ofdateis not that string. The value is aDateobject, so in the diff it makes that clear.