karma: Strange error trying to run Jasmine specs

callum:tool-test $ gulp test
[gulp] Using file /Users/madebymany/tool-test/gulpfile.js
[gulp] Working directory changed to /Users/madebymany/tool-test
[gulp] Running 'scripts'...
[gulp] Finished 'scripts' in 4.52 ms
[gulp] Running 'test'...
/Users/madebymany/tool-test/src/main.js
[gulp] Starting Karma server...

/Users/madebymany/tool-test/node_modules/gulp-karma/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 (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/lib/server.js:29:14
    at Array.forEach (native)
    at start (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/lib/server.js:28:21)
    at invoke (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/Users/madebymany/tool-test/node_modules/gulp-karma/node_modules/karma/lib/server.js:272:12)
    at Object.<anonymous> (/Users/madebymany/tool-test/node_modules/gulp-karma/lib/background.js:3:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
[gulp] Finished 'test' in 566 ms

I have tried reinstalling Karma and associated modules. Explicitly installing karma-jasmine didn’t seem to work (http://stackoverflow.com/questions/19185548/no-provider-error-on-karma-serve-running-angularjs-phonecat-tutorial).

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 24 (5 by maintainers)

Most upvoted comments

I had the same problem. Adding ‘karma-jasmine’, ‘karma-chrome-launcher’ in the plugins fixed it.

  plugins : [
        require('karma-webpack'),
        'karma-jasmine',
        'karma-chrome-launcher'
    ]

Yes removed global karma then installed karma-cli globally. thereafter i installed karma local to project and then runned karma.

  1. npm uninstall karma -g
  2. npm install karma-cli -g
  3. npm install karma --save-dev
  4. grunt karma test -v Still getting “Warning: No provider for “framework:jasmine”! (Resolving: framework:jasmine)”. Please help.

Thanks

@garora Try remove global karma and install karma-cli global. Then install karma local to the project and run karma.

Thanks

Karma needs to load the plugins (such as karma-jasmine). By default (if you don’t specify config.plugins), Karma loads all the karma-* modules that are siblings to Karma.

It sounds like you have Karma installed globally (npm install -g karma) and jasmine plugin locally (npm install karma-jasmine). If that’s the case, install Karma locally.

The recomended way is to install Karma and all the plugins locally, per project.

I resolved this problem with this conf:

frameworks: ['jasmine'],
plugins: [
    require("karma-jasmine"),
 ]

by the way, i also get:

{ Error: Cannot find module 'PhantomJS'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)...

with:

browsers: ['PhantomJS'],

and I also resolved this problem with:

plugins: [
   require("karma-phantomjs-launcher")
],

maybe this will help somebody.