expect.not.arrayContaining(array)

expect.not.arrayContaining(array) matches a received array which does not contain all of the elements in the expected array. That is, the expected array is not a subset of the received array.

It is the inverse of expect.arrayContaining.

  1. describe('not.arrayContaining', () => {
  2. const expected = ['Samantha'];
  3. it('matches if the actual array does not contain the expected elements', () => {
  4. expect(['Alice', 'Bob', 'Eve']).toEqual(
  5. expect.not.arrayContaining(expected),
  6. );
  7. });
  8. });