title: unit test mock - node 17 + typescript + ESM module
body: <p>There is a simple question I cannot find an answer to.
  When using:</p>
  <ol>
  <li>Node 17 + Typescript</li>
  <li>ESM (&quot;type&quot;: &quot;module&quot; in package.json)</li>
  </ol>
  <p><strong>Can I implement mock</strong> for one function only? or module?</p>
  <p>If so, can I get an example?
  No matter what framework you use.</p>
  <p>thanks!!</p>
  <p>package.json:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;test&quot;: &quot;node --experimental-vm-modules  ./node_modules/.bin/jest --bail --colors --coverage --detectOpenHandles --forceExit --verbose&quot;,
  
      &quot;jest&quot;: {
          &quot;preset&quot;: &quot;ts-jest/presets/default-esm&quot;,
          &quot;transform&quot;: {
              &quot;.ts&quot;: &quot;ts-jest&quot;
          },
          &quot;testEnvironment&quot;: &quot;node&quot;,
          &quot;moduleFileExtensions&quot;: [
              &quot;ts&quot;,
              &quot;js&quot;,
              &quot;json&quot;
          ],
          &quot;transformIgnorePatterns&quot;: [
              &quot;&lt;rootDir&gt;/node_modules/&quot;
          ],
          &quot;globals&quot;: {
              &quot;ts-jest&quot;: {
                  &quot;useESM&quot;: true
              }
          }
      }
  }
  </code></pre>
  <p>Jest.spy gives me an error: cannot assign to read-only property I tried using Sinon too, and I got: es modules cannot be stubbed</p>