title: Jest: test that an array contains none of these values?
body: <p>I want to verify that a given array doesn't contain any of a list of values. There is <code>expect.arrayContaining</code> but I don't get how it is supposed to be used for this.</p>
  <p>See this example:</p>
  <pre class="lang-js prettyprint-override"><code>expect([&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]).not.toEqual(expect.arrayContaining([&quot;3&quot;])
  </code></pre>
  <p>This test fails which is the expected behavior. I want to verify that &quot;3&quot; is not included in the array. Everything fine.</p>
  <p>However, now I have multiple values for which I want the test to fail if the array contains any of them.</p>
  <pre class="lang-js prettyprint-override"><code>expect([&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]).not.toEqual(expect.arrayContaining([&quot;3&quot;, &quot;4&quot;])
  </code></pre>
  <p>This test does not fail even though I would expect it to fail because the array contains the &quot;3&quot;.</p>
  <p>What I could do is this:</p>
  <pre class="lang-js prettyprint-override"><code>expect([&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]).not.toEqual(expect.arrayContaining([&quot;3&quot;])
  expect([&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]).not.toEqual(expect.arrayContaining([&quot;4&quot;])
  ...
  </code></pre>
  <p>But having to repeat the whole expect line for every single value doesn't seem to be the right way. Especially when <code>arrayContaining</code> takes an array as argument while it looks like you can only pass it a single value to be useful.</p>
  <p>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 &quot;blacklist&quot;.</p>