I am working off of this tutorial: http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/ as a means to understand what files are created using yo generator-angular.
我正在学习本教程:http://www.sitepoint.com/kickstart- angularjs-development-with-yeoman-grunt-and-bower/作为一种理解使用yo generator- angle创建什么文件的方法。
I have experience using AngularJS, but was looking for a way to get a best-practices directory set up; I am not sure how to set up dependencies and get karma running on my own, hence using the yeoman generator.
我有使用AngularJS的经验,但正在寻找建立最佳实践目录的方法;我不确定如何建立依赖关系并让业力自己运行,因此使用约曼发生器。
However, straight out of the box, without editing anything else, when I run grunt test I get the following:
然而,在没有编辑任何其他内容的情况下,直接开箱操作,当我运行grunt测试时,我得到以下结果:
running "clean:server" (clean) task
Cleaning .tmp...OK
Running "concurrent:test" (concurrent) task
Running "copy:styles" (copy) task
Copied 1 files
Done, without errors
Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/main.css" created.
Running "connect:test" (connect) task
Started connect web server on 127.0..0.1:9001.
Running "karma:unit" (karma) task
Warning: No provider for "framework:jasmine"! (resolving: framework:jasmine) Use --force to continue.
Aborted due to warnings.
I don't understand why jasmine has no provider, and not sure how to go about resolving this issue. is it a matter of fixing my package.json files and updating node?
我不明白为什么jasmine没有提供者,也不知道如何解决这个问题。是修理我的包裹的问题吗?json文件和更新节点?
EDIT: Here is the config file:
编辑:这里是配置文件:
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks:['jasmine'],
// list of files / patterns to load in the browser
files: [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/scripts/*.js',
'app/scripts/**/*.js',
'test/mock/**/*.js',
'test/spec/**/*.js'
],
// list of files / patterns to exclude
exclude: [],
// web server port
port: 8080,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
};
3 个解决方案
#1
54
I seem to have fixed my problem, for anyone with a similar problem:
我似乎已经解决了我的问题,对于任何有类似问题的人:
Within my karma.conf.js I added the following:
在我karma.conf。js我添加了以下内容:
plugins: [
'karma-chrome-launcher',
'karma-jasmine'
],
At first I added 'karma-jasmine' but was then met with "Can not load "Chrome", it is not registered!" This was solved by adding 'karma-chrome-launcher' as a plug-in
一开始我添加了“karma-jasmine”,但是后来遇到了“无法载入”的Chrome,它没有注册!通过添加“karma-chrome-launcher”作为插件解决了这个问题
Not sure if it was my fault or whether generator-angular is out of date, but it is now working.
不知道是我的错,还是发电机的角度过时了,但它现在正在起作用。
#2
10
The github issue pointed out by @Jim Schubert has this comment:
@Jim Schubert指出的github问题有以下评论:
The full list of karma dependencies that I needed to install to get tests working (coffeescript).
为了让测试工作,我需要安装的业力依赖项的完整列表(coffeescript)。
npm install --save-dev karma-chrome-launcher karma-firefox-launcher karma-safari-launcher karma-opera-launcher karma-ie-launcher karma-jasmine karma-coffee-preprocessor
#3
2
If you used the --coffee
flag on the yo angular
command you'll need to:
如果你在yo角命令中使用-coffee flag,你需要:
install some browser launcher (chrome in this case) and the following npm packages:
安装一些浏览器启动程序(本例中为chrome)和以下npm包:
npm install --save-dev karma-chrome-launcher karma-jasmine karma-coffee-preprocessor
and add the following to your karma.conf.js file:
在你的karma.conf中加入以下内容。js文件:
plugins:['karma-chrome-launcher', 'karma-jasmine', 'karma-coffee-preprocessor'],
preprocessors:{'**/*.coffee':['coffee']}
After that running grunt test
should work.
在运行后,咕哝测试应该可以工作。
#1
54
I seem to have fixed my problem, for anyone with a similar problem:
我似乎已经解决了我的问题,对于任何有类似问题的人:
Within my karma.conf.js I added the following:
在我karma.conf。js我添加了以下内容:
plugins: [
'karma-chrome-launcher',
'karma-jasmine'
],
At first I added 'karma-jasmine' but was then met with "Can not load "Chrome", it is not registered!" This was solved by adding 'karma-chrome-launcher' as a plug-in
一开始我添加了“karma-jasmine”,但是后来遇到了“无法载入”的Chrome,它没有注册!通过添加“karma-chrome-launcher”作为插件解决了这个问题
Not sure if it was my fault or whether generator-angular is out of date, but it is now working.
不知道是我的错,还是发电机的角度过时了,但它现在正在起作用。
#2
10
The github issue pointed out by @Jim Schubert has this comment:
@Jim Schubert指出的github问题有以下评论:
The full list of karma dependencies that I needed to install to get tests working (coffeescript).
为了让测试工作,我需要安装的业力依赖项的完整列表(coffeescript)。
npm install --save-dev karma-chrome-launcher karma-firefox-launcher karma-safari-launcher karma-opera-launcher karma-ie-launcher karma-jasmine karma-coffee-preprocessor
#3
2
If you used the --coffee
flag on the yo angular
command you'll need to:
如果你在yo角命令中使用-coffee flag,你需要:
install some browser launcher (chrome in this case) and the following npm packages:
安装一些浏览器启动程序(本例中为chrome)和以下npm包:
npm install --save-dev karma-chrome-launcher karma-jasmine karma-coffee-preprocessor
and add the following to your karma.conf.js file:
在你的karma.conf中加入以下内容。js文件:
plugins:['karma-chrome-launcher', 'karma-jasmine', 'karma-coffee-preprocessor'],
preprocessors:{'**/*.coffee':['coffee']}
After that running grunt test
should work.
在运行后,咕哝测试应该可以工作。