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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)