Tag: deepequals

在deepEqual中奇怪的新date

我有这个代码 var assert = require('assert'); describe('date', function() { it('deep equal', function() { assert.deepEqual({date: ''}, {date:new Date()}); }); }); 当我用摩卡进行testing时,我得到了这个 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) 为什么deepEqual生成的date格式为[Date: 2017-03-08T21:58:45.767Z]而不是这种格式2017-03-08T21:58:45.767Z ? 为什么生成的date在括号[Date: …] ?

如何用should.js做一个deepEqual断言?

我试图用should.js(最新版本)做一个deepEqual断言,并没有任何成功。 我可以让事情equal而不是与deepEqual一起deepEqual 。 事实上,我看到没有deepEqual方法。 以下是我所尝试的: > require('should') {…} > > var x = Number(8) undefined > x.should.equal(8) { obj: 8 } > x.should.equal(9) AssertionError: expected 8 to equal 9 at …. > x.should.deepEqual(8) TypeError: Object #<Object> has no method 'deepEqual' 很公平。 现在看着should ,我看到它是一个getter: > Object.getOwnPropertyDescriptor(Object.prototype, 'should') { get: [Function], set: [Function], enumerable: false, configurable: true […]