title: Cypress Best Practice - Store and compare two values
body: <p>I want to store a value, then perform an action and assert that the value has not changed. I do have a code that works but I would like to have input if there is a more elegant solution.</p>
  <p>The basic idea is:</p>
  <ul>
  <li>Get the number or results displayed ('counts'), store it in a .then() function</li>
  <li>Change the use</li>
  <li>Get the number of results displayed ('new_counts'), store it in a new .then function</li>
  <li>Compare counts and new_counts in the 2nd .then() function</li>
  </ul>
  <pre class="lang-js prettyprint-override"><code>describe('Store and compare a value', () =&gt; {
      it('store and compare', () =&gt; {
  
          cy.login()
          cy.visit('url2')
          cy.get('.total-count-results').invoke('text')
              .then((text) =&gt; {
                  const counts = text 
                  cy.get('.medium.col100 &gt; .filterwrapper &gt; input').type('Test Dummy',{force: true})
                  cy.get('.medium.col100 &gt; .filterwrapper &gt; input').type('{enter}')
                  cy.get('.total-count-results').invoke('text')
                      .then((text) =&gt; {
                          const new_counts = text
                          expect(new_counts).to.eq(counts)
                      })
              })
      })
  })
  </code></pre>
  <p>That is the best I could come up with to handle asynchronicity.</p>