karma-runner / karma-coffee-preprocessor

A Karma plugin. Compile coffee script on the fly.
MIT License
53 stars 34 forks source link

Error - Can not load "coffee", it is not registered! #35

Open AsmaGargouri opened 8 years ago

AsmaGargouri commented 8 years ago

I installed the plugin with the command ; npm install --save-dev karma-coffee-preprocessor I then configured my test config file as follows:

module.exports = function(config) {
  config.set({

    basePath: '',
    frameworks: ['jasmine'],
    files: [
        '../bower_components/angular/angular.js',
        '../bower_components/angular-ui-router/release/angular-ui-router.js',
        '../bower_components/angular-mocks/angular-mocks.js',
        '../src/scripts/**/*.coffee',
        'unit-tests/**/*.js'
    ],

    exclude: [
    ],

    preprocessors: {
        '../src/scripts/**/*.coffee': ['coffee']
    },

    coffeePreprocessor: {
      options: {
        bare: true,
        sourceMap: false
      },
      transformPath: function(path) {
        return path.replace(/\.coffee$/, '.js')
      }
    },

    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['PhantomJS'],
    singleRun: false,
    concurrency: Infinity
  })
}

But when I try to start my test I have this error :

 Can not load "coffee", it is not registered!
  Perhaps you are missing some plugin?
/opt/node/lib/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
      ^

Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
    at error (/opt/node/lib/node_modules/karma/node_modules/di/lib/injector.js:22:12)
    at Object.parent.get (/opt/node/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/opt/node/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /opt/node/lib/node_modules/karma/lib/server.js:138:20
    at Array.forEach (native)
    at Server._start (/opt/node/lib/node_modules/karma/lib/server.js:137:21)
    at invoke (/opt/node/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Server.start (/opt/node/lib/node_modules/karma/lib/server.js:102:18)
    at Object.exports.run (/opt/node/lib/node_modules/karma/lib/cli.js:243:26)
    at Object.<anonymous> (/opt/node/lib/node_modules/karma/bin/karma:3:23)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:146:18)

Can anyone help me ?

jakkor commented 8 years ago

Add karma-coffee-preprocessor to plugins. For me it was: plugins: [ 'karma-phantomjs-launcher', 'karma-jasmine', 'karma-coffee-preprocessor' ]