I want to verify that a given array doesn't contain any of a list of values. There is expect.arrayContaining but I don't get how it is supposed to be used for this.
See this example:
expect(["1", "2", "3"]).not.toEqual(expect.arrayContaining(["3"])
This test fails which is the expected behavior. I want to verify that "3" is not included in the array. Everything fine.
However, now I have multiple values for which I want the test to fail if the array contains any of them.
expect(["1", "2", "3"]).not.toEqual(expect.arrayContaining(["3", "4"])
This test does not fail even though I would expect it to fail because the array contains the "3".
What I could do is this:
expect(["1", "2", "3"]).not.toEqual(expect.arrayContaining(["3"])
expect(["1", "2", "3"]).not.toEqual(expect.arrayContaining(["4"])
...
But having to repeat the whole expect line for every single value doesn't seem to be the right way. Especially when arrayContaining takes an array as argument while it looks like you can only pass it a single value to be useful.
I'm sure there are valid use-cases for this behavior but I'm asking how I can implement by use-case in a more concise way. Basically, I want the test to fail as soon as the array contains one or more values of the second array. Sort of a "blacklist".