title: Jest: Spy on object method?
body: <p>I need to spy on <code>Date.toISOString()</code> and return a value.</p>
  <p><code>const spy = jest.spyOn(global, Date);</code>
  spies on Date global</p>
  <p><code>const spy = jest.spyOn(global, 'get', Date);</code>
  spies on Date global get</p>
  <p>But how do you spy on the object methods? And return a value?</p>
  <pre><code>const spy = jest.spyOn(global.Date, 'toISOString').mockImplementation(() =&gt; {
          return new Date().now()
        })
  </code></pre>
  <p><code>Cannot spy the toISOString property because it is not a function; undefined given instead</code></p>
  <pre><code>const spy = jest.spyOn(global.Date.toISOString).mockImplementation(() =&gt; {
          return new Date().now()
        })
  </code></pre>
  <p><code> Cannot spyOn on a primitive value; undefined given</code></p>