title: How do I assert against objects with spies in Cypress?
body: <p>I am using Cypress spies to test client-side analytics. </p>
  
  <p>My intent in this test is to confirm that <code>identify</code> has been called like so:</p>
  
  <p><code>identify('myemail@email.com', { groupId: 1002, groupName: "myGroup", someProp: 1, anotherProp: 2 })</code></p>
  
  <p>I hook the spies into emitter events on a global <code>analytics</code> object in <code>window:before:load</code> (note the <code>while</code> loop is to deal with delays in the library loading):</p>
  
  <pre><code>Cypress.on("window:before:load", async (win: Window) =&gt; {
  
    const sleep = (n = 1) =&gt; new Promise(r =&gt; setTimeout(r, n));
    let set = false;
    while (set === false) {
      if (win["analytics"]) {
        set = true;
        const a = win["analytics"];
        const pageSpy = cy.spy().as("page");
        const idSpy = cy.spy().as("identify");
        a.on("page", pageSpy);
        a.on("identify", idSpy);
  
      } else {
         // default sleep of 1ms. this is b/c there's a super tight
         // window from analytics init and the calls I'm looking to
         // track (~25ms)
        await sleep();
        continue;
      }
    }
  });
  </code></pre>
  
  <p>The intent here is that every time a <code>page</code> or <code>identify</code> method is called, the spy is called with the args from the <code>page</code> / <code>identify</code> call. </p>
  
  <p>Then, in my test: </p>
  
  <pre><code> it("calls identify on page load", () =&gt; {
      const idProps = {
        groupId: 1002,
        groupName: "myGroup",
        someProp: 1,
        anotherProp: 2
      };
  
      cy.visit("https://mypage.com");
  
      cy.get("@identify").should(
        "be.calledWith",
        "myemail@email.com"
      ).and("be.calledWith",idProps);
    });
  </code></pre>
  
  <p>The first assertion passes (<code>"be.calledWith", "myemail@email.com"</code>).</p>
  
  <p>The second assertion, however, fails: </p>
  
  <pre><code>Command:  get
  cypress_runner.js:141344 Alias:    @identify
  cypress_runner.js:141344 Yielded:  ƒ identify
  cypress_runner.js:141344 Error:    CypressError: Timed out retrying: expected identify to have been called with arguments Object{4}
  
      The following calls were made:
  
      identify("myemail@email.com", Object{4}, undefined) at o.proxy (https://exmaple.com/__cypress/runner/cypress_runner.js:45839:22)
  </code></pre>
  
  <p>I have tried using <code>sinon.match</code>, but that <a href="https://github.com/cypress-io/cypress/issues/1328" rel="nofollow noreferrer">isn't supported in Cypress' version of sinon</a>.</p>
  
  <p>I also tried extracting the raw calls / args (ie <code>spy.getCalls()</code>), but this doesn't seem to be supported when accessing the spy via an alias (i.e. <code>cy.get('@identify')</code>). </p>
  
  <p>So: is there any way to deep match the args passed to a cypress spy?</p>