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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)