lazd / gulp-karma

Karma plugin for gulp
MIT License
75 stars 36 forks source link

Error: No provider for "framework:jasmine" #4

Closed hhelwich closed 10 years ago

hhelwich commented 10 years ago

i get the following error:

./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 (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at ./node_modules/gulp-karma/node_modules/karma/lib/server.js:29:14
    at Array.forEach (native)
    at start (./node_modules/gulp-karma/node_modules/karma/lib/server.js:28:21)
    at invoke (./node_modules/gulp-karma/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (./node_modules/gulp-karma/node_modules/karma/lib/server.js:272:12)
    at Object.<anonymous> (./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:901:3

If i start karma from console it works as expected (./node_modules/.bin/karma run).

snichme commented 10 years ago

I've got the same error

tregusti commented 10 years ago

I get this for framework:mocha.

pshomov commented 10 years ago

Same here

koblass commented 10 years ago

I found the problem. gulp-karma is looking into "node_modules\gulp-karma\node_modules" to find the modules instead of "node_modules". If you install all the requested modules there it's working, but I've trouble now with angular. I receive the following error "Uncaught ReferenceError: angular is not defined". My angular.js file is well added in the configuration and anyway my karma.conf.js is correct because it works perfectly if I run it from webstorm.

Would be nice to have this plugin fixed asap as this is a must have...

lazd commented 10 years ago

@koblass, thanks for checking into this. This plugin will be getting a bit of an overhaul and will likely end up gulp-friendly, but not as a gulp-plugin. I'll make sure to address this and #3 in the process.

joeLepper commented 10 years ago

Made a quick gist that defines a quick and dirty task that I'm using as a stopgap until this module works as expected: https://gist.github.com/joeLepper/8347279

Needless to say, I'm experiencing this issue as well.

pshomov commented 10 years ago

I did the same as @joeLepper but it might be a better alternative simply to fork the project and add the karma-jasmine package (and whatever other karma plugins one happens to use) to it and then use the fork. Have to manually merge upstream changes of course ;(

tregusti commented 10 years ago

I solved it by adding a plugins option in karma cconfig file.

http://karma-runner.github.io/0.10/config/configuration-file.html

It should be an array of the names of all used plugins.

phedinkus commented 10 years ago

I added the plugins to my karma.config.js and I'm still having problems running karma with jasmine through gulp.

shorttompkins commented 10 years ago

+1 this is an issue for me currently.

sectore commented 10 years ago

As @koblass mentioned before installing plugins into node_modules/gulp-karma/node_modules seems to be a good workaround. Also, here are no issues using Angular.

Example: https://github.com/ws-slideshow/ws-slideshow-app/blob/master/gulpfile.coffee

Instruction for running test: https://github.com/ws-slideshow/ws-slideshow-app#tests

tregusti commented 10 years ago

It's a workaround, good however it is not. It means the dependency specification in your package.json isn't good enough for the whole team, including those not too tech savvy/used to the command line.

Well. grunt-karma seems to have solved it, so maybe someone with some time can look into it. I have other gulps to fix =)

sectore commented 10 years ago

@tregusti Agree! So I figured out that defining plugins AND frameworks within Karmas config file solves this issue - as you mentioned before. No workaround needed anymore... Thanks for your hint!

Example of Karma config https://github.com/ws-slideshow/ws-slideshow-app/blob/master/test/karma.conf.coffee

tregusti commented 10 years ago

Sorry, didn't think about mentioning frameworks, I had it in my config, didn't think it was related. Glad it worked out for you.

lazd commented 10 years ago

This is issue is similar to #5.

Karma will load plugins local to it by default. Since the version of karma that gulp-karma was using was inside of gulp-karma/node_modules, karma-jasmine was not available for discovery.

I made karma a peerDependency of gulp-karma, which causes it to be installed in the project itself (not it it's own node_modules folder), allowing automatic discovery of plugins.

Closed by a1d34ece9738afcc152c73b2a0d6642f711f21b5. Please try with gulp-karma@0.0.2, your issue should be fixed.

In other cases where you get this error, try specifying the plugin in the plugins array (see Karma docs on plugins):

  plugins: [
      'karma-coverage',
      'karma-jasmine',
      'karma-chrome-launcher',
      'karma-firefox-launcher'
  ]
hhelwich commented 10 years ago

:+1: thanks!

jsdevel commented 10 years ago

@lazd I'm still seeing this issue after doing yo angular && npm te. I'm completely new to Yeoman, so I apologize if I'm posting this in the wrong spot. Can you help?

Thanks!

lazd commented 10 years ago

@jsdevel, I can't comment on what the problem might be. Try StackOverflow, and provide your configuration or a sample repository that reproduces the error.

jsdevel commented 10 years ago

Thanks!

grantgeorge commented 10 years ago

I ran into this problem earlier today.

To fix: add "karma-jasmine" and "karma-chrome-launcher" (or whatever launcher you use) to the devDependencies in packages.json and run npm install again.

npm install karma-jasmine --save-dev

npm install karma-chrome-launcher --save-dev

http://stackoverflow.com/questions/22421857/error-no-provider-for-frameworkjasmine-resolving-frameworkjasmine/22600674#22600674

chanced commented 10 years ago

@grantgeorge - thanks, I was missing karam-chrome-launcher

grantgeorge commented 10 years ago

@chanced - No problem, glad I could help!

Javilete commented 10 years ago

@grantgeorge - thanks, I was able to fix it, I did not have those dependencies. :+1:

fuqcool commented 10 years ago

Thank you @grantgeorge!

mmahalwy commented 9 years ago

hmm having this problem now :(

quantuminformation commented 8 years ago

I'm having this issue, I'm only wanting to run mocha.

Error: No provider for "framework:mocha"! (Resolving: framework:mocha)

my conf:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['mocha'],
    files: [
      'src/**/*.js', 'src/**/__spec__/*.js'
    ],
    exclude: [],
    preprocessors: {},
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome', 'IE', 'PhantomJS', 'Safari', 'Firefox'],
    singleRun: false,
    concurrency: Infinity
  })
}

related package:

    "gulp-watch": "^1.1.0",
    "jasmine": "^2.3.1",
    "jasmine-core": "^2.4.1",
    "jscs": "^1.7.3",
    "jshint": "^2.5.6",
    "karma-jasmine": "^0.3.6",
    "minimist": "^1.1.0",
    "mocha": "^2.3.4",

I'm running Karma through webstorm.

gesilar commented 8 years ago

i had the issue before,and i solved this problem by install karma concerned modules to global env.it`s a directly way to run your test modules but not the best way to solve the problem.

reddynr commented 8 years ago

I am getting error below error while running karma test. anybody have work around. much appreciated. Thanks

Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)

reddynr commented 8 years ago

here is my karma.config file. any help much appreciated. Thanks

// Karma configuration // Generated on Thu Oct 13 2016 12:05:23 GMT-0400 (Eastern Daylight 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

// list of files / patterns to load in the browser files: [ 'lib/angular.min.js', 'lib/angular-mocks.js', 'app/.js', 'tests/.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: {
},

// 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,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity

}) }

segevsh commented 7 years ago

I struggled with the exact same problem. After investigating I realized that karma was running globally using '/usr/' directory as the base folder.

A solution that worked for me was to replace karma with karma-cli:

    npm remove -g karma
    npm install -g karma-cli