title: How to spy on window.scrollTo in Jest?
body: <p>I got a very simple react component with following functionallity:</p>
  
  <pre><code>componentDidMount() {
    window.scrollTo(0, 0)
  }
  </code></pre>
  
  <p>It seems that you cannot do something like</p>
  
  <pre><code>window.scrollTo = jest.fn()
  </code></pre>
  
  <p>to spy on <code>scrollTo</code> function. </p>
  
  <p>Therefor, I want to know what is the best way to spy on this function and assert that it has been used in my tests. </p>
  
  <p>Thanks </p>