karma icon indicating copy to clipboard operation
karma copied to clipboard

Strange error trying to run Jasmine specs

Open callum opened this issue 12 years ago • 24 comments

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).

callum avatar Jan 08 '14 17:01 callum

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.

vojtajina avatar Jan 20 '14 20:01 vojtajina

@vojtajina - I tried above steps but still I am getting the same issue. I have also tried with Visual Studio 2013 on Windows7 (64 bit) machine.

Unofrtunately, I am getting the same exception (on console) as mentioned above. In VS2013 its showing 'INFO: Starting karma server...'

P.S.: For vs2013, I am using Plugin

garora avatar Sep 25 '14 13:09 garora

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

Thanks

maksimr avatar Sep 25 '14 15:09 maksimr

I am getting same error as garora. Tried all steps as by vojtajina but still getting this error. Any suggestions what to do?

munishmehta27 avatar Dec 11 '14 02:12 munishmehta27

@munishmehta27 Did you remove global karma?

maksimr avatar Dec 11 '14 14:12 maksimr

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

munishmehta27 avatar Dec 12 '14 09:12 munishmehta27

@munishmehta27 can you post your karma.config.js and package.json?

maksimr avatar Dec 12 '14 10:12 maksimr

Yes i did but issue is still there!!!

Please suggest

On Thu, Dec 11, 2014 at 8:28 PM, Maksim Ryzhikov [email protected] wrote:

@munishmehta27 https://github.com/munishmehta27 Did you remove global karma?

— Reply to this email directly or view it on GitHub https://github.com/karma-runner/karma/issues/880#issuecomment-66630137.

munishmehta27 avatar Dec 14 '14 13:12 munishmehta27

Hi Maksim,

Please find the attached ....

Thanks

On Fri, Dec 12, 2014 at 4:25 PM, Maksim Ryzhikov [email protected] wrote:

@munishmehta27 https://github.com/munishmehta27 can you post your karma.config.js and package.json?

— Reply to this email directly or view it on GitHub https://github.com/karma-runner/karma/issues/880#issuecomment-66758568.

munishmehta27 avatar Dec 14 '14 13:12 munishmehta27

Any progress with this, @munishmehta27 or @maksimr? I'm experiencing the same issue. Below are my config files. Thanks in advance!

EDIT: I found the error in the below karma.config.js file. The configuration file specified a plugins configuration which was only setup to load the karma-webpack module. This caused the default "load all karma-* modules" to be abandoned and hence the karma-jasmine module was not loaded. On to the next!

// Karma configuration
// Generated on Mon Feb 09 2015 11:38:40 GMT-0700 (Mountain Standard Time)

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

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'app/build/*',
      'Test/*Spec.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        'app/build/*': ['webpack', 'sourcemap'],
        'Test/*Spec.js': ['webpack', 'sourcemap'],
    },


    webpack: {
        devtool: 'inline-source-map'
    },


    webpackMiddleware: {
        // webpack-dev-middleware configuration
        noInfo: true
    },


    plugins: [
        require("karma-webpack")
    ],


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};

package.json

{
  "name": "RVC",
  "version": "0.0.1",
  "description": "",
  "main": " ",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "css-loader": "^0.9.0",
    "exports-loader": "^0.6.2",
    "expose-loader": "^0.6.0",
    "imports-loader": "^0.6.3",
    "jasmine-core": "^2.2.0",
    "karma": "^0.12.31",
    "karma-chrome-launcher": "^0.1.7",
    "karma-ie-launcher": "^0.1.5",
    "karma-jasmine": "^0.3.5",
    "karma-sourcemap-loader": "^0.3.3",
    "karma-webpack": "^1.5.0",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.8.2"
  },
  "dependencies": {
    "knockout": "^3.2.0",
    "page": "^1.5.0",
    "webpack": "^1.4.14"
  }
}

vinneyk avatar Feb 09 '15 19:02 vinneyk

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'
    ]

raphaelhudvoy avatar Apr 29 '15 18:04 raphaelhudvoy

Why this is closed?

garora avatar Apr 29 '15 22:04 garora

Resolved this issue by checking if I had karma/jasmine installed globally:

npm ls -g karma
npm ls -g jasmine

Removed both, then npm install -g karma-cli and have jasmine+karma only locally installed

jorgenbs avatar Jun 05 '15 07:06 jorgenbs

I had the same problem and the @raphaelhudvoy suggestion to add 'karma-jasmine' in the plugins inside karma.config.js fixed it.

rajeshtulika avatar Sep 03 '15 06:09 rajeshtulika

Still having problem with VS2015

garora avatar Sep 06 '15 07:09 garora

I can confirm that adding 'karma-jasmine' to the plugins works. I kinda wonder why the karma init does not add it if it becomes a necessary step now.

I have karma-cli installed globally, and karma, karma-jasmine locally.

npx avatar Sep 09 '15 04:09 npx

I had the same problem, and uninstalling the global instance of karma fixed it for me, too. Since this is a 1.5 year old bug, it would make sense if the dev team found an actual fix for this...

EightArmCode avatar Oct 06 '15 12:10 EightArmCode

Its again broke my dev environment

garora avatar Oct 08 '15 13:10 garora

@EightArmCode it's not bug. If you run global karma then karma will try find global karma-jasmine that logical. Special for this case was made karma-cli which run project instance of karma that solve this issue.

Thanks!

maksimr avatar Oct 08 '15 14:10 maksimr

npm install -g karma-cli worked for me

ws-perelyaynen avatar Apr 13 '16 08:04 ws-perelyaynen