Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  85] [ 6]  / answers: 1 / hits: 120008  / 11 Years ago, sat, march 30, 2013, 12:00:00

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])


Neither seems to work.


More From » jasmine

 Answers
118

Just did the test and it works with toEqual



please find my test:



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]);
});
});


Just for information:




toBe() versus toEqual(): toEqual() checks equivalence. toBe(), on the
other hand, makes sure that they're the exact same object.



[#79232] Thursday, March 28, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
demondp

Total Points: 154
Total Questions: 97
Total Answers: 99

Location: Mali
Member since Thu, Jul 9, 2020
4 Years ago
;