Jasmine: Testing if two arrays contain the same elements

Posted . Visible to the public.

When the order matters:

expect(array1).toEqual(array2)

Regardless of order:

expect(array1).toEqual(jasmine.arrayWithExactContents(array2))

Ignoring extra elements:

expect(array1).toEqual(jasmine.arrayContaining(array2))
Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2022-02-12 12:43)