title: React testing library: Cannot find module declared in .d.ts
body: <p>thx for your time.</p>
  <p>I have a problem with react testing library. Everything work in browser. I can build, <strong>but when run the tests</strong>, jest cannot find typescript definitions.</p>
  <p><a href="https://i.stack.imgur.com/BAutT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BAutT.png" alt="enter image description here" /></a></p>
  <p>If I use React lazy to import components, error cannot appear.</p>
  <p>In my case is <code>UI.d.ts</code>.
  UI come from webpack module federation:</p>
  <pre><code>new ModuleFederationPlugin({
      name: &quot;root&quot;,
      filename: &quot;remoteEntry.js&quot;,
      remotes: { UI: process.env.UI_REMOTE_URL },
      shared: {
          ...deps,
          react: {
              singleton: true,
              requiredVersion: deps.react
          },
          &quot;react-dom&quot;: {
              singleton: true,
              requiredVersion: deps[&quot;react-dom&quot;]
          }
      }
  }),
  </code></pre>
  <p><code>UI.d.ts</code> is in root directory. Project tree:</p>
  <pre><code>├── README.md
  ├── UI.d.ts
  ├── package.json
  ├── public/
  ├── src/
  ├── tsconfig.json
  ├── webpack.config.js
  ├── yarn-error.log
  └── yarn.lock
  </code></pre>
  <p><code>tsconfig.json</code>:</p>
  <pre><code>{
    &quot;exclude&quot;: [
      &quot;node_modules&quot;,
      &quot;./packages/**/node_modules&quot;
    ],
    &quot;compilerOptions&quot;: {
      &quot;target&quot;: &quot;es5&quot;,
      &quot;lib&quot;: [
        &quot;dom&quot;,
        &quot;dom.iterable&quot;,
        &quot;esnext&quot;
      ],
      &quot;allowJs&quot;: true,
      &quot;skipLibCheck&quot;: true,
      &quot;esModuleInterop&quot;: true,
      &quot;allowSyntheticDefaultImports&quot;: true,
      &quot;strict&quot;: true,
      &quot;forceConsistentCasingInFileNames&quot;: true,
      &quot;noFallthroughCasesInSwitch&quot;: true,
      &quot;module&quot;: &quot;esnext&quot;,
      &quot;moduleResolution&quot;: &quot;node&quot;,
      &quot;resolveJsonModule&quot;: true,
      &quot;isolatedModules&quot;: true,
      &quot;noEmit&quot;: false,
      &quot;jsx&quot;: &quot;react-jsx&quot;
    },
    &quot;include&quot;: [
      &quot;src&quot;,
      &quot;**/*.d.ts&quot;
    ]
  }
  </code></pre>