Skip to content

Jest expect to array contains element

Let’s suppose that I have the following code: And I want to check if id is in arrayOfIds Something like this How can I do this with Jest? Answer Use .toContain when you want to check that an item is in an array. For testing the items in the array, this uses ===, a strict equality check.