expect.arrayContaining() matches an array that contains all of the elements in the expected array, in any order. Note that received array may be a superset of the expected array and contain some extra elements.
expect.arrayContaining()
Use this method inside expect(value).toEqual(expected) to perform pattern matching.
Usage
expect([1, 2, 3]).toEqual(expect.arrayContaining([3, 1]));expect([1, 2, 3]).not.toEqual(expect.arrayContaining([1, 4])); Copy
expect([1, 2, 3]).toEqual(expect.arrayContaining([3, 1]));expect([1, 2, 3]).not.toEqual(expect.arrayContaining([1, 4]));
Expected array that is a subset of the received value.
expect.arrayContaining()matches an array that contains all of the elements in the expected array, in any order. Note that received array may be a superset of the expected array and contain some extra elements.Use this method inside expect(value).toEqual(expected) to perform pattern matching.
Usage