title: object.hasOwnProperty is not a function when spying on es6 module
body: <p>So I'm doing a little bit of experimental programming to ensure I understand how certain things work, and I'm coming across an error which I don't understand. I can't see any obvious solutions for this problem using Google or on here specifically.</p>
  <p>I'm trying to confirm to myself exactly how <code>jest.spyOn()</code> works when applied to module imports. But right now the answer is that it just doesn't.</p>
  <p>spy.js:</p>
  <pre><code>export const foo = () =&gt; {
    console.log(&quot;called foo&quot;);
  };
  
  export const bar = () =&gt; {
    console.log(&quot;called bar&quot;);
  };
  </code></pre>
  <p>spy.spec.js:</p>
  <pre><code>import * as Foo from &quot;./spy&quot;;
  import { jest } from &quot;@jest/globals&quot;;
  
  test(&quot;call foo&quot;, () =&gt; {
    jest.spyOn(Foo, &quot;bar&quot;);
  });
  </code></pre>
  <p>package.json:</p>
  <pre><code>{
    &quot;type&quot;: &quot;module&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;NODE_OPTIONS=--experimental-vm-modules jest --watch&quot;
    },
    &quot;dependencies&quot;: {
      &quot;jest&quot;: &quot;^27.0.1&quot;
    }
  }
  </code></pre>
  <p>When I run this test, I get the following error: <code>TypeError: object.hasOwnProperty is not a function</code>. I'm running node v15.12.0.</p>
  <p>Can somebody explain to my</p>
  <ol>
  <li>Why this error occurs</li>
  <li>What I can do to remove it</li>
  </ol>
  <p><em>Edit</em></p>
  <p>It has been suggested that the problem is to do with the module import lacking a <code>prototype</code> property. This is not the issue - see below</p>
  <pre><code>import * as Foo from &quot;./spy&quot;;
  import { jest } from &quot;@jest/globals&quot;;
  
  test(&quot;SpyOn plain object&quot;, () =&gt; {
    const bar = { baz: () =&gt; {} };
    expect(bar.prototype).toBeUndefined(); // Pass
    jest.spyOn(bar, &quot;baz&quot;); // No error
  });
  
  test(&quot;SpyOn import&quot;, () =&gt; {
    expect(Foo.prototype).toBeUndefined(); // Pass
    jest.spyOn(Foo, &quot;foo&quot;); // Error!
  });
  </code></pre>