title: Typescript with Mocha / Chai / Sinon global namespace issues
body: <p>Does anyone know the correct way to set up testing with ts-node in typescript to have Mocha and Chai and Sinon all recognized globally without the need to manually import in every test file? I have all types definitions included in the project, including mocha, sinon, chai. I have the following (which works and runs tests correctly):</p>
  
  <p>mocha.opts:</p>
  
  <pre><code>--require ts-node/register
  --option value spec/**/*.spec.ts
  --require spec/bootstrap/test-setup.js
  --recursive
  --retries 0
  --sort
  --timeout 10000
  --ui bdd
  </code></pre>
  
  <p>Test script in package.json:</p>
  
  <pre><code>"test": "yarn build &amp;&amp; NODE_ENV=test nyc mocha ./spec/bootstrap/test-helper.js --opts ./spec/mocha.opts"
  </code></pre>
  
  <p>I have 2 helper methods (which for some reason I have to do in JS)</p>
  
  <p>test-setup.js:</p>
  
  <pre><code>require('mocha');
  var chai = require('chai');
  chai.use(require('chai-as-promised'));
  chai.use(require('sinon-chai'));
  
  global.expect = chai.expect;
  global.Promise = require('bluebird');
  </code></pre>
  
  <p>test-helper.js:</p>
  
  <pre><code>const sinon = require('sinon');
  const _ = require('lodash');
  const db = require('../../src/models');
  
  before(() =&gt; {
    global.sandbox = sinon.sandbox.create();
  });
  
  afterEach(function () {
    global.sandbox.restore();
  });
  
  after(() =&gt; {
    db.default.sequelize.close();
  });
  </code></pre>
  
  <p>Finally a junk spec for testing setup:</p>
  
  <pre><code>describe('app', () =&gt; {
    const bar = {
      foo: () =&gt; 1,
    };
  
    it('asserts 1 === 1', () =&gt; {
      const stub = sandbox.stub(bar, 'foo').returns(3);
      const result = bar.foo();
      expect(result).to.eq(3);
      expect(stub).to.have.callCount(1);
      expect(1).to.eq(1);
    });
  
    it('tests stubs reset', () =&gt; {
      expect(bar.foo()).to.eq(1);
    });
  
  });
  </code></pre>
  
  <p>A couple notes here:</p>
  
  <ol>
  <li>This works, it transpiles and runs the tests correctly. If i remove the seemingly pointless <code>require('mocha')</code> it shows error highlighting for <code>it</code> and <code>describe</code> as well, but again still runs.</li>
  <li>The only "issue" is the error highlighting and lack of auto complete for sinon and chai stuff in vs code. This is very close to my test setup in node js, which works 100% fine.</li>
  </ol>
  
  <p>Here is what I see:
  <a href="https://i.stack.imgur.com/G0TRg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/G0TRg.png" alt="Faulty error highlighting"></a></p>
  
  <p>But again I stress, this works, it just feels dubiously hacky and I would like to figure out if I can A) do this all in TS, rather than having JS setup files, and B) fix incorrect ts error highlighting in this scenario.</p>