title: Using webpack aliases in mocha tests
body: <p>I'm developing a web app at work in React/Redux/Webpack and am now starting to integrate testing with Mocha.</p>
  
  <p>I followed <a href="http://rackt.org/redux/docs/recipes/WritingTests.html" rel="noreferrer">the instructions for writing tests in the Redux documentation</a>, but now I have run into an issue with my webpack aliases.</p>
  
  <p>For example, take a look at the imports section of this test for one of my action creators:</p>
  
  <pre><code>import expect       from 'expect'                 // resolves without an issue
  import * as actions from 'actions/app';           // can't resolve this alias
  import * as types   from 'constants/actionTypes'; // can't resolve this alias
  
  describe('Actions', () =&gt; {
    describe('app',() =&gt; {
      it('should create an action with a successful connection', () =&gt; {
  
        const host = '***************',
              port = ****,
              db = '******',
              user = '*********',
              pass = '******';
  
        const action = actions.createConnection(host, port, db, user, pass);
  
        const expectedAction = {
          type: types.CREATE_CONNECTION,
          status: 'success',
          payload: { host, port, database, username }
        };
  
        expect(action).toEqual(expectedAction);
      });
    });
  });
  </code></pre>
  
  <p>As the comments suggest, mocha isn't able to resolve my import statements when they are referencing aliased dependencies. </p>
  
  <p>Because I'm still new to webpack, here's my <code>webpack.config.js</code>:</p>
  
  <pre><code>module.exports = {
    devtool: 'eval-source-map',
    entry: [
      'webpack-hot-middleware/client',
      './src/index'
    ],
    output: {
      path: path.join(__dirname, 'dist'),
      filename: 'bundle.js',
      publicPath: '/static/'
    },
    resolve: {
      extensions : ['', '.js', '.jsx'],
      alias: {
        actions: path.resolve(__dirname, 'src', 'actions'),
        constants: path.resolve(__dirname, 'src', 'constants'),
        /* more aliases */
      }
    },
    plugins: [
      new webpack.optimize.OccurenceOrderPlugin(),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.NoErrorsPlugin()
    ],
    module: {
      loaders: [{
        test: /\.js$/,
        loaders: ['babel'],
        exclude: /node_modules/,
        include: __dirname
      }]
    }
  };
  </code></pre>
  
  <p>Also, I'm using the command <code>npm test</code> to run mocha, here's the script I'm using in my <code>package.json</code>.</p>
  
  <pre><code> {   
     "scripts": {
       "test": "mocha ./src/**/test/spec.js --compilers js:babel-core/register --recursive"
     }
   }
  </code></pre>
  
  <p>So here's where I get stuck. <strong>I need to include the aliases from webpack into mocha when it runs.</strong> </p>