babel/karma-babel-preprocessor

Karma WARN [preprocess]: Can not load "babel", it is not registered!

leehambley opened this issue · 4 comments

According to the Karma instructions (more or less empty, just some files in files/)

// vim: ft=javascript

module.exports = function(config) {
  config.set({
    frameworks: ['qunit'],
    plugins: ['karma-qunit'],
    files: [
      "node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js",
      "src/**/*.es6",
      "test/**/*.es6"
    ],
    preprocessors: {
      "src/**/*.es6":  ["babel"],
      "test/**/*.es6": ["babel"]
    },
    "babelPreprocessor": {
      options: {
        sourceMap: "inline"
      },
      filename: function(file) {
        return file.originalPath.replace(/\.js$/, ".es6.js");
      },
      sourceFileName: function(file) {
        return file.originalPath;
      }
    }
  });
};

The error:

./node_modules/karma/bin/karma start
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
WARN [preprocess]: Can not load "babel", it is not registered!
  Perhaps you are missing some plugin?

What have I done wrong? package.json looks like this:

{
  "name": "eventdomtree",
  "version": "1.0.0",
  "description": "",
  "main": "karma.conf.js",
  "dependencies": {

  },
  "devDependencies": {
    "babel": "^4.7.16",
    "karma-babel-preprocessor": "^4.0.1",
    "karma": "^0.12.31",
    "karma-qunit": "^0.1.4",
    "qunitjs": "^1.17.1",
    "karma-qunit": "^0.1.4"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Try adding 'karma-babel-preprocessor' to your plugins

Worked perfectly, for node newbies, might I suggest a tweak to the README next time you're in that file?

Thanks!

@leehambley Thanks for your feedback. I didn't notice this because we don't need karma's plugins option in most cases. I added a section about it to README.