title: How do I partially compare deeply nested objects in Cypress assertions?
body: <p>I'm using <a href="https://www.cypress.io" rel="nofollow noreferrer">Cypress</a> as my automation framework for both API and UI tests. I've written multiple API tests that are running and passing but they're only validating that the <code>response.status</code> returns a <code>200</code>. I want to compare the response json from a <code>GET</code> against a stored &quot;expected&quot; response to confirm that the JSON response data is correct.</p>
  <p>I've tried different variations of <code>to.deep.equal</code> and <code>deepEquals</code> in my <code>.then(response =&gt; {}</code> code block. But I don't want to validate that just one field is returning the correct value, I want to validate whether a bunch of different fields are returning the correct values. My <code>GET</code> request returns over 100 lines of nested JSON fields/values and I only want to validate 20 or so fields/values nested inside each other.</p>
  <pre class="lang-javascript prettyprint-override"><code>cy.request({
      method: 'GET',
      log: true,
      url: 'https://dev.api.random.com/calculators/run-calculate/524/ABC',
  
      headers: {
          'content-type': 'application/json',
          'x-api-key': calcXApiKey
      },
      body: {}
  }).then(response =&gt; {
      const respGet = response.body
      const tPrice = response.body.data.calculations.t_costs[0].comparison.t_price
      cy.log(respGet, tPrice)
      assert.deepEqual({
          tPrice
      }, {
          t_price: '359701'
      })
         // assert.equal(response.status, 200) -- This works great
  })
  </code></pre>
  <p>Error= <code>expected { tPrice: undefined } to deeply equal { t_price: 359701 }</code></p>