最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I make should.js assertions about dates? - Stack Overflow

programmeradmin0浏览0评论

I've got a unit test like this:

(parsed.date).should.equal(new Date(2006,06,18,18,07));

Which fails with this message:

  AssertionError: expected 2006-07-19T00:07:00.000Z to be 2006-07-19T00:07:00.000Z
  + expected - actual

What am I doing wrong?

I've got a unit test like this:

(parsed.date).should.equal(new Date(2006,06,18,18,07));

Which fails with this message:

  AssertionError: expected 2006-07-19T00:07:00.000Z to be 2006-07-19T00:07:00.000Z
  + expected - actual

What am I doing wrong?

Share Improve this question asked Apr 12, 2014 at 12:25 Sam MikesSam Mikes 10.8k3 gold badges43 silver badges47 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

Found it - I should be comparing dates with eql not equal.

Working code:

(parsed.date).should.eql(new Date(2006,06,18,18,07));

More at this link: https://github.com/visionmedia/should.js/issues/63 specifically comment https://github.com/visionmedia/should.js/issues/63#issuecomment-27626023

发布评论

评论列表(0)

  1. 暂无评论