const path = require('path');
const webpackConf = require('./webpack.config.js');
const optional = require('optional');
const mochaConf = optional('./local/mocha.opts.json') || {};

webpackConf.module.rules.unshift({
  enforce: 'pre',
  test: /\.(js)$/,
  loader: 'isparta-loader',
  include: [
    path.join(__dirname, '/../src'),
  ],
});

webpackConf.externals = {
  cheerio: 'window',
  'react/addons': true,
  'react/lib/ExecutionEnvironment': true,
  'react/lib/ReactContext': true,
};

webpackConf.devtool = 'inline-source-map';

module.exports = function karmaConfig(config) {
  config.set({
    browsers: ['PhantomJS'],
    captureTimeout: 60000,
    browserNoActivityTimeout: 60000,
    singleRun: true,
    logLevel: config.LOG_INFO,
    colors: true,
    frameworks: ['mocha', 'chai', 'sinon', 'intl-shim'],
    client: {
      mocha: mochaConf,
    },
    files: [
      'loadtests.js',
    ],
    preprocessors: {
      'loadtests.js': ['webpack', 'sourcemap'],
    },
    reporters: ['mocha', 'coverage'],
    webpack: webpackConf,
    webpackMiddleware: {
      noInfo: true,
      stats: {
        chunks: false,
      },
    },
    coverageReporter: {
      dir: 'coverage/',
      reporters: [
        { type: 'html' },
        { type: 'text' },
      ],
    },
  });
};

@@ -1,34 +1,4 @@
-const path = require('path');%0A
 cons
@@ -149,168 +149,8 @@
 %7D;%0A%0A
-webpackConf.module.rules.unshift(%7B%0A  enforce: 'pre',%0A  test: /%5C.(js)$/,%0A  loader: 'isparta-loader',%0A  include: %5B%0A    path.join(__dirname, '/../src'),%0A  %5D,%0A%7D);%0A%0A
 webp
@@ -403,16 +403,53 @@
 g.set(%7B%0A
+    browserNoActivityTimeout: 60000,%0A
     brow
@@ -504,253 +504,330 @@
     
-browserNoActivityTimeout: 60000,%0A    singleRun: true,%0A    logLevel: config.LOG_INFO,%0A    colors: true,%0A    frameworks: %5B'mocha', 'chai', 'sinon', 'intl-shim'%5D,%0A    client: %7B%0A      mocha: mochaConf,%0A    %7D,%0A    files: %5B%0A      'loadtests.js',%0A    %5D
+client: %7B%0A      mocha: mochaConf,%0A    %7D,%0A    colors: true,%0A    coverageReporter: %7B%0A      dir: 'coverage/',%0A      reporters: %5B%0A        %7B type: 'html' %7D,%0A        %7B type: 'text' %7D,%0A      %5D,%0A    %7D,%0A    files: %5B%0A      'loadtests.js',%0A    %5D,%0A    frameworks: %5B'mocha', 'chai', 'sinon', 'intl-shim'%5D,%0A    logLevel: config.LOG_INFO
 ,%0A  
@@ -934,24 +934,45 @@
 coverage'%5D,%0A
+    singleRun: true,%0A
     webpack:
@@ -1088,143 +1088,8 @@
  %7D,%0A
-    coverageReporter: %7B%0A      dir: 'coverage/',%0A      reporters: %5B%0A        %7B type: 'html' %7D,%0A        %7B type: 'text' %7D,%0A      %5D,%0A    %7D,%0A
   %7D)

Clean up karma conf