我写了一个非常基本的测试,测试应该会成功,但古怪的事实并非如此。摩卡测试失败,但它不应该
it('should add the card to the tapis', function(){
tapis.insererTapis(new Card("O", 5));
tapis.insererTapis(new Card("E", 3));
tapis.tapis.should.equal([{
suit: "E",
val: 3
},{
suit: "O",
val: 5
}]);
done();
});
我在控制台这个奇怪的错误运行mocha test.js
0 passing (8ms)
1 failing
1) tapis should add the card to the tapis:
AssertionError: expected [ { suit: 'E', val: 3 }, { suit: 'O', val: 5 } ] to be [ { suit: 'E', val: 3 }, { suit: 'O', val: 5 } ]
+ expected - actual
`
后,大约should.js模块的问题吗?
也侧面说明你并不需要'做()'同步测试,因为这和异步测试,你确实需要它,你都必须声明它作为测试功能的函数参数,并调用它完成时。 –
是的,我知道的是,我刚刚加入'done',看看这个错误有事情做与同步/异步。 – hamou92