Jasmine.js 比较数组
jasmine.js中有没有办法检查两个数组是否相等,例如:
Is there a way in jasmine.js to check if two arrays are equal, for example:
arr = [1, 2, 3]
expect(arr).toBe([1, 2, 3])
expect(arr).toEqual([1, 2, 3])
似乎都不起作用.
推荐答案
刚刚做了测试,它可以与 toEqual
Just did the test and it works with toEqual
请找到我的测试:
http://jsfiddle.net/7q9N7/3/
describe('toEqual', function() {
it('passes if arrays are equal', function() {
var arr = [1, 2, 3];
expect(arr).toEqual([1, 2, 3]);
});
});
仅供参考:
toBe() 与 toEqual():toEqual() 检查等价性.toBe(),在另一方面,确保它们是完全相同的对象.
toBe() versus toEqual(): toEqual() checks equivalence. toBe(), on the other hand, makes sure that they're the exact same object.
相关文章