title: How to resolve "Cannot use import statement outside a module" in jest
body: <p>I have a React application (not using Create React App) built using TypeScript, Jest, Webpack, and Babel. When trying to run <code>yarn jest</code>, I get the following error:</p>
  <p><img src="https://i.imgur.com/bkIisp8.png" alt="jest error" /></p>
  <p>I have tried removing all packages and re-adding them.  It does not resolve this.  I have looked at similar questions and documentation and I am still misunderstanding something. I went so far as to follow another guide for setting up this environment from scratch and still received this issue with my code.</p>
  <p>Dependencies include...</p>
  <pre><code>&quot;dependencies&quot;: {
    &quot;@babel/plugin-transform-runtime&quot;: &quot;^7.6.2&quot;,
    &quot;@babel/polyfill&quot;: &quot;^7.6.0&quot;,
    &quot;babel-jest&quot;: &quot;^24.9.0&quot;,
    &quot;react&quot;: &quot;^16.8.6&quot;,
    &quot;react-dom&quot;: &quot;^16.8.6&quot;,
    &quot;react-test-renderer&quot;: &quot;^16.11.0&quot;,
    &quot;source-map-loader&quot;: &quot;^0.2.4&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@babel/core&quot;: &quot;^7.6.0&quot;,
    &quot;@babel/preset-env&quot;: &quot;^7.6.0&quot;,
    &quot;@babel/preset-react&quot;: &quot;^7.0.0&quot;,
    &quot;@types/enzyme&quot;: &quot;^3.9.2&quot;,
    &quot;@types/enzyme-adapter-react-16&quot;: &quot;^1.0.5&quot;,
    &quot;@types/jest&quot;: &quot;^24.0.13&quot;,
  </code></pre>
  <p>The component's import lines...</p>
  <pre><code>import * as React from &quot;react&quot;;
  import { BrowserRouter as Router, Route, Switch } from &quot;react-router-dom&quot;;
  import HomePage from &quot;./components/pages&quot;;
  import {
    Footer,
    Header,
    Navigation,
  } from &quot;./components/shared&quot;;
  </code></pre>
  <p>The test file....</p>
  <pre><code>import * as React from &quot;react&quot;;
  import * as renderer from &quot;react-test-renderer&quot;;
  import App from &quot;../App&quot;;
  
  it(&quot;Renders the Footer correctly&quot;, () =&gt; {
    const tree = renderer
      .create(&lt;App /&gt;)
      .toJSON();
    expect(tree).toMatchSnapshot();
  });
  </code></pre>
  <p>I expected to be able to use named imports in my components without my tests blowing up.  It appears to fix the issue if I only use default imports through my solution, but I would prefer to not go that route.</p>