业力/茉莉测试angularjs的配置会抛出:没有供应商"框架:茉莉"! [英] configuration of karma/jasmine to test angularjs throws: No provider for "framework:jasmine"!
问题描述
您好,我想实现单元测试与业力和茉莉花angularjs。我跟着因此,本教程:
http://tech.pro/tutorial/1473/getting-started -with-angularjs单元测试
Hello I'm trying to implement unit-tests for angularjs with karma and jasmine. I followed therefore this tutorial: http://tech.pro/tutorial/1473/getting-started-with-angularjs-unit-testing
在该点运行首
测试我得到因错误而吸:
On the point Running Your First
Test I get sucked because of an error:
没有供应商!框架:茉莉花
No provider for "framework:jasmine"!
我GOOGLE了它,并试图建议之类的东西重新安装卡玛 - 茉莉和因果报应 - 铬 - 发射器,但这些都不为我工作。
I googled for it and tried the suggested things like installing karma-jasmine and karma-chrome-launcher again but none of these worked for me.
我的package.json看起来是这样的:
My package.json looks like this:
{
"name": "projectName",
"version": "1.0.0",
"description": "a description",
"dependencies": {
"gulp": "^3.5.6",
"gulp-sass": "^1.3.3",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^0.3.0",
"gulp-rename": "^1.2.0"
},
"devDependencies": {
"bower": "^1.3.3",
"gulp-util": "^2.2.14",
"jasmine-core": "^2.3.4",
"karma": "^0.12.36",
"karma-chrome-launcher": "^0.1.12",
"karma-jasmine": "^0.3.5",
"karma-safari-launcher": "^0.1.1",
"shelljs": "^0.3.0"
},
"cordovaPlugins": [
"org.apache.cordova.device",
"org.apache.cordova.console",
"com.ionic.keyboard"
],
"cordovaPlatforms": [
"android",
"ios"
]
}
和我人缘配置karma.conf.js:
And my karma configuration karma.conf.js:
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: [
'test/*/Specs.js',
'test/*'
],
// 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', 'Safari'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
如果我跑因缘开始karma.conf.js
我总是得到错误。我甚至改变了这两个文件的许可,无任何影响。有什么问题吗?
If I run karma start karma.conf.js
I always get the error. I even changed the permission of these two files without any effect. What is the problem here?
推荐答案
原来,我已经安装了全球范围内的业力 NPM安装在本地-g人缘
和因果报应,茉莉 NPM安装卡玛 - 茉莉
。我重新安装了卡玛 - 茉莉全球,现在它的工作。
It turned out that I have installed karma globally npm install -g karma
and karma-jasmine locally npm install karma-jasmine
. I reinstalled karma-jasmine globally and now its working.
这篇关于业力/茉莉测试angularjs的配置会抛出:没有供应商"框架:茉莉"!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!