title: Cypress assertion fails but test passes
body: <p>Doing some integration tests on API.
  One of the tests passes and the other fails when assertions are basically the same.
  Confused about how cypress handles async/promises.</p>
  <pre><code>context(&quot;Login&quot;, () =&gt; {
    // This test fails
    it(&quot;Should return 401, missing credentials&quot;, () =&gt; {
      cy.request({
        url: &quot;/auth/login&quot;,
        method: &quot;POST&quot;,
        failOnStatusCode: false
      }).should(({ status, body }) =&gt; {
        expect(status).to.eq(401) // Passes
        expect(body).to.have.property(&quot;data&quot;) // Passes
                    .to.have.property(&quot;thisDoesntExist&quot;) // Fails
      })
    })
    
    // This test passes
    it(&quot;Should return 200 and user object&quot;, async () =&gt; {
      const token = await cy.task(&quot;generateJwt&quot;, users[0])
      cy.request({
        url: &quot;/auth/me&quot;,
        method: &quot;GET&quot;,
        headers: {
          Authorization: `Bearer ${token}`,
          &quot;Content-type&quot;: &quot;application/json&quot;
        }
      }).should(({ status, body }) =&gt; {
        expect(status).to.eq(200) // Passes
        expect(body).to.have.property(&quot;data&quot;) // Passes
                    .to.have.property(&quot;thisDoesntExist&quot;) // Fails
      })
    })
  })
  </code></pre>
  <p><strong>EDIT:</strong>
  I fixed it by doing this:</p>
  <pre><code> it(&quot;Should return 200 and user object&quot;, () =&gt; {
      cy.task(&quot;generateJwt&quot;, users[0]).then((result) =&gt; {
        const token = result
        cy.request({
          url: &quot;/auth/me&quot;,
          method: &quot;GET&quot;,
          headers: {
            Authorization: `Bearer ${token}`,
            &quot;Content-type&quot;: &quot;application/json&quot;
          }
        }).should(({ status, body }) =&gt; {
          expect(status).to.eq(200)
          expect(body)
            .to.have.property(&quot;data&quot;)
            .to.have.property(&quot;thisDoesntExist&quot;)
        })
      })
    })
  </code></pre>
  <p><strong>Why does it pass when using async/await?</strong></p>
  <p><a href="https://i.stack.imgur.com/PxBMj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PxBMj.png" alt="Tests" /></a></p>