title: How to fix this Jest error: "component encountered a declaration exception"?
body: <p>I'm trying to test a React component using Jest and Enzyme. My test is very simple at the moment, I'm just trying to make sure the component mounts:</p>
  
  <pre><code>import React from 'react';
  import Enzyme, { shallow } from 'enzyme';
  import EnzymeAdapter from 'enzyme-adapter-react-16';
  import App from './App';
  
  Enzyme.configure({
    adapter: new EnzymeAdapter()
  });
  
  describe('App Component', () =&gt; {
    const app = shallow(&lt;App /&gt;);
  
    it('renders successfully', () =&gt; {
      expect(app).toMatchSnapshot();
    });
  });
  </code></pre>
  
  <p>Running it gives the following error:</p>
  
  <pre><code>App Component › encountered a declaration exception
  TypeError: window.TimerSDK is not a constructor
  </code></pre>
  
  <p>The offending line in question is this bit of code:</p>
  
  <pre><code>this.timerSDK = new window.TimerSDK({ accessToken: token });
  </code></pre>
  
  <p><code>TimerSDK</code> is a third party script that is loaded via a script tag in <code>index.html</code>. It's not imported like an es6 module.</p>
  
  <p>The code above works fine in the browser when actually using the app but when running the test it errors out.</p>
  
  <p>How to fix this?</p>