title: Cypress-wait-until - wait for element attribute to change
body: <p>I am testing an app that has a button that causes a value in another element on screen to change, without reloading the page. However, that change in value can be almost instant, or take several seconds. Obviously, I don't want to use some arbitrary wait, and I don't want to use a (hard) assertion - that might cause the test to stop with a fail that isn't a fail.... so I've been looking at cypress-wait-until (<a href="https://www.npmjs.com/package/cypress-wait-until" rel="nofollow noreferrer">https://www.npmjs.com/package/cypress-wait-until</a>). I've written assorted variations along the lines of:</p>
  <pre><code>    waitForElemToChange(elem) {
          elem.invoke('attr', val').then((initialVal) =&gt; {
          cy.waitUntil(() =&gt; elem.invoke('attr', 'value').then((val) =&gt; val != initialVal))
      }
  </code></pre>
  <p>But nothing has worked so far - most attempts have resulted in &quot;Timed out retrying: cy.invoke() errored because your subject is: null. You cannot invoke any functions such as attr on a null value.&quot;</p>
  <p>Yet it's the same subject that just returned a value in the previous line??</p>