【发布时间】:2018-07-17 19:33:18
【问题描述】:
我第一次使用 mocha 和 chai,不知道发生了什么?我想说我的 shuffle 方法已经移动了数组对象并且第一个数组对象不再 - “sam1” IE -
describe('Shuffle', function(){
it('Shuffle should randomly move array items by their index', function(){
let group = ["sam1","sam2","sam3","sam4","sam5","sam6","sam7","sam8","sam9"];
let result = shuffle(group);
assert.equal(result, group[0] != "sam1");
});
});
这是错误-
AssertionError: expected [ Array(9) ] to equal true
我如何比较两者以使其正确?还是有更好的方法来显示数组已被洗牌?
【问题讨论】:
-
我知道你没有问……但如果你的随机播放真的是随机的,那么一个项目就有可能在它开始的地方结束。
标签: javascript testing mocha.js chai