jasmine.js中有没有办法检查两个数组是否相等,例如:
arr = [1, 2, 3]
expect(arr).toBe([1, 2, 3])
expect(arr).toEqual([1, 2, 3])
似乎都不起作用。
最佳答案
刚刚进行了测试,它适用于 toEqual
请找到我的测试:
describe('toEqual', function() {
it('passes if arrays are equal', function() {
var arr = [1, 2, 3];
expect(arr).toEqual([1, 2, 3]);
});
});
仅供引用:
toBe() versus toEqual(): toEqual() checks equivalence. toBe(), on the other hand, makes sure that they're the exact same object.
关于javascript - Jasmine.js 比较数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15717844/