Read more

Jasmine: Testing if two arrays contain the same elements

Henning Koch
February 12, 2022Software engineer at makandra GmbH

When the order matters:

expect(array1).toEqual(array2)
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Regardless of order:

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

Ignoring extra elements:

expect(array1).toEqual(jasmine.arrayContaining(array2))
Posted by Henning Koch to makandra dev (2022-02-12 13:43)