title: Problem testing array of objects using Jest.js with similar properties
body: <p>I am testing two arrays with objects, say arr1, arr2 respectively.</p>
  <p>I want to test for every object in arr1, there exists an object in arr2 that is a subset of the object in arr1, meaning the key:value pairs of the object in arr2 exist in the object in arr1 we are comparing to at the moment.</p>
  <p>For example:</p>
  <pre><code>let arr1 = [
      {
          &quot;appName&quot;: &quot;configapi&quot;,
          &quot;region&quot;: &quot;aa&quot;
        },
        {
          &quot;appName&quot;: &quot;catalogapi&quot;,
          &quot;region&quot;: &quot;aa&quot;
        },
        {
          &quot;appName&quot;: &quot;orderapi&quot;,
          &quot;region&quot;: &quot;aa&quot;
        }
      ]
  
  let arr2 = [
    {
      appName: 'configapi',
      region: 'aa',
      status: HttpStatus.OK,
      version: global.AppVersion,
      environment: process.env.NODE_ENV,
      commit: {
        hash: process.env.COMMIT_HASH,
        created: process.env.COMMIT_TIME,
      },
    },
    {
      appName: 'catalogapi',
      region: 'aa',
      status: HttpStatus.OK,
      version: global.AppVersion,
      environment: process.env.NODE_ENV,
      commit: {
        hash: process.env.COMMIT_HASH,
        created: process.env.COMMIT_TIME,
      },
    },
    {
      appName: 'orderapi',
      region: 'aa',
      status: HttpStatus.OK,
      version: global.AppVersion,
      environment: process.env.NODE_ENV,
      commit: {
        hash: process.env.COMMIT_HASH,
        created: process.env.COMMIT_TIME,
      },
    }];
  </code></pre>
  <p>This is what I wrote so far:</p>
  <pre><code>expect(arr2).toEqual(expect.arrayContaining(arr1.map((val =&gt; expect.objectContaining(val)))),
      );
  </code></pre>
  <p>but I'm not sure if this encapsulates the logic I explained earlier. I've already looked at the jest docs if there are expect array methods that accomplish what I want but I was unable to find a good solution.</p>