Skip to content
Advertisement

JEST – check if objects array is a subset of another array

Using JEST I want to test if an array of objects is a subset of another array.

I want to test the following:

JavaScript

I’ve tried the following:

JavaScript

But this is not correct since objectContaining doesn’t accept array as param … it works only if subset is a single object.

Advertisement

Answer

I’ve never tried this myself, but wouldn’t it work to just say:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement