title: Testing: mocha + typescript + webpack
body: <p>I'm using TypeScript, Mocha (with mocha-typescript plugin) for testing and WebPack for build in my application.</p>
  
  <p>Recently I decided to add DefinePlugin for WebPack to separate configs for prod and dev environments:</p>
  
  <pre><code>import { AppSettings as DevSettings } from './appSettings.dev'
  import { AppSettings as ProdSettings } from './appSettings.prod'
  
  declare var __ENVIRONMENT__: string;
  
  let settings = __ENVIRONMENT__ === 'prod' ? ProdSettings : DevSettings
  
  export let AppSettings = settings;
  </code></pre>
  
  <p>In snippet above there is a global variable <code>__ENVIRONMENT__</code> , which helps to choose settings I want to use. This variable is defined in webpack.config.js as follows:</p>
  
  <pre><code>module.exports = function(env) {
      var config = {
          // ...
          plugins: [
              new ExtendedDefinePlugin({
                  __ENVIRONMENT__: env === 'prod' ? 'prod' : 'dev',
              })
          ]
          // ...
      }
  
      return config;
  }
  </code></pre>
  
  <p>So I change tests execution in package.json to</p>
  
  <pre><code>"test": "webpack --env=dev &amp;&amp; mocha --recursive"
  </code></pre>
  
  <p>If I call "test", mocha throw error (webpack builds files correctly):</p>
  
  <pre><code>ReferenceError: __ENVIRONMENT__ is not defined
  </code></pre>
  
  <p>Testing watcher also won't work:</p>
  
  <pre><code>"test-watch": "mocha-typescript-watch"
  </code></pre>
  
  <p>throwing error "Exited with 1".</p>
  
  <p>Is it possible to bring them work together? Or shall I use another way for testing?</p>