Running only single changed test file using Karma with Webpack
<p>I've got a working Karma setup, using Webpack. Whenever I modify either a test file or any of its dependencies, <strong>all</strong> of the tests run. This is all good, but <strong>I'd really like it to run only the minimum number of tests</strong>. If I change a test file, it should run only that test file. If I change a source file, it should run whatever test files have that source file as a dependency (via <code>require</code>).</p>

<p>Here's the relevant portion of my <code>karma.config.js</code>:</p>

<pre><code>files: [
  {
    pattern: '**/*.test.js',
    watched: true,
    included: true,
    served: true
  },
],

preprocessors: {
  '**/*.test.js': ['webpack']
},

webpack: {
  resolve: {
    root: path.join(__dirname, '..', 'webpack'),
    extensions: ['', '.js', '.jsx'],
  },

  module: {
    loaders: [
      {
        test: /.jsx?$/,
        loader: 'babel-loader',
        exclude: [/node_modules/],
        query: {
          presets: ['es2015', 'react']
        }
      },
    ]
  },
},
</code></pre>

<p>The complete <code>karma.config.js</code> file is <a href="https://gist.github.com/fweep/edd7ada15f43d648feb8e1f16d899366" rel="nofollow noreferrer">in a gist</a>.</p>

<p>I'm familiar with solutions mentioned in <a href="https://stackoverflow.com/questions/26603402/how-do-i-run-only-certain-tests-in-karma">other questions</a>, involving <code>process.env.npm_config_single_file</code>, but that's not what I'm trying to do. </p>

<p>Based on my config above, I'm expecting it to handle each file as a separate webpack, which is also implied by the documentation 
at the top of <a href="https://github.com/webpack/karma-webpack" rel="nofollow noreferrer">webpack/karma-webpack</a>. Instead, what I seem to get is a single webpack with two chunks, per the log:</p>

<pre><code>                      Asset     Size  Chunks             Chunk Names
employee_list_entry.test.js  1.07 MB       0  [emitted]  employee_list_entry.test.js
employer_list_entry.test.js  1.07 MB       1  [emitted]  employer_list_entry.test.js
chunk    {0} employee_list_entry.test.js (employee_list_entry.test.js) 1.01 MB
</code></pre>

<p>It always rebuilds both chunks even when I only save one test file.</p>