Closed hhelwich closed 10 years ago
I've got the same error
I get this for framework:mocha.
Same here
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...
@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.
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.
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 ;(
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.
I added the plugins to my karma.config.js and I'm still having problems running karma with jasmine through gulp.
+1 this is an issue for me currently.
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
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 =)
@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
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.
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'
]
:+1: thanks!
@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!
@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.
Thanks!
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
@grantgeorge - thanks, I was missing karam-chrome-launcher
@chanced - No problem, glad I could help!
@grantgeorge - thanks, I was able to fix it, I did not have those dependencies. :+1:
Thank you @grantgeorge!
hmm having this problem now :(
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.
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.
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)
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
}) }
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
i get the following error:
If i start karma from console it works as expected (
./node_modules/.bin/karma run
).