title: Babel [karma-babel-preprocessor] Not Converting ES6->ES5 for Karma Tests
body: <p>We have installed karma, which is using mocha and chai for tests. We are trying to integrate babel straight into karma using karma-babel-preprocessor, to do the converting of our ES6 files into ES5 to be run. Using mocha individually works with babel, i.e. a mocha test command, but we try to use karma instead it doesn't work.</p>
  
  <p>karma.conf.js snippet:</p>
  
  <pre><code>frameworks: ['mocha', 'chai'],
  
  // preprocess matching files before serving them to the browser
  // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  preprocessors: {
     'src/**/*.js': ['babel'],
     'test/**/*_spec.js': ['babel']
  },
  
  "babelPreprocessor": {
      options: {
          presets: ['es2015'],
          sourceMap: 'inline'
      },   
      filename: function(file) {
          return file.originalPath.replace(/\.js$/, '.es5.js');
      },
      sourceFileName: function(file) {
          return file.originalPath;
      }
  },
  
  // list of files / patterns to load in the browser
  files: [
    'src/**/*.js',
    'test/**/*_spec.js'
  ],
  </code></pre>
  
  <p>package.json snippets:</p>
  
  <pre><code>"scripts": {
    "test": "./node_modules/karma/bin/karma start karma.conf.js"
  },
  
  "babel": {
    "presets": ["es2015"]
  },
  
  "devDependencies": {
    "babel-preset-es2015": "^6.1.18",
    "chai": "^3.4.1",
    "karma": "^0.13.15",
    "karma-babel-preprocessor": "^6.0.1",
    "karma-chai": "^0.1.0",
    "karma-mocha": "^0.2.1",
    "karma-phantomjs-launcher": "^0.2.1",
    "phantomjs": "^1.9.18",
    "redux": "^3.0.4"
  }
  </code></pre>
  
  <p>We get the following error:</p>
  
  <pre><code>PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
    ReferenceError: Can't find variable: exports
    at Users/alexgurr/BT/FutureVoice/trunk/Portal/server/src/login.es5.js:3
  </code></pre>
  
  <p>When we evaluate the JS files being loaded, they haven't been converted to ES5, hence the syntax 'export' is still present.</p>
  
  <p>We don't want to use any other frameworks for conversion, ie. webpack, browserify etc.</p>
  
  <p>Thanks!</p>