我在32位Win7机器上安装了Karma。我得到了它的工作,但它需要许多曲折的段落来完成所有工作。我从Maven运行它。
我现在正在64位Win7机器上进行设置。我已经设法安装和运行Karma,甚至通过我的测试,但我的大多数必需的插件都收到“无法找到插件”的警告。请注意,我没有在构建脚本本身中进行任何更改。这在32位盒子上没有改变。
以下是我的构建输出示例:
[INFO] --- maven-karma-plugin:1.5:start (default) @ SunlightGUI-war --- cmd /C karma start C:\Users\=myuid=\workspace\SunlightGUI\src\test\webapp\js\karma.conf.js --browsers PhantomJS --reporters dots,junit,coverage --single-run --no-auto-watch --colors false WARN [plugin]: Cannot find plugin "karma-coverage". Did you forget to install it ? npm install karma-coverage --save-dev WARN [plugin]: Cannot find plugin "karma-junit-reporter". Did you forget to install it ? npm install karma-junit-reporter --save-dev WARN [plugin]: Cannot find plugin "karma-ie-launcher". Did you forget to install it ? npm install karma-ie-launcher --save-dev WARN [reporter]: Can not load "junit", it is not registered! Perhaps you are missing some plugin? WARN [reporter]: Can not load "coverage", it is not registered! Perhaps you are missing some plugin? INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/ INFO [launcher]: Starting browser PhantomJS WARN [preprocess]: Can not load "coverage", it is not registered! Perhaps you are missing some plugin? INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket QADs66EmM2NRD8wGWyJu LOG: LOG 'JQMIGRATE: Logging is active'LOG: WARN 'JQMIGRATE: jQuery.browser is deprecated'LOG: WARN 'JQMIGRATE: AJAX events should be attached to document: ajaxComplete'................... PhantomJS 1.9.7 (Windows 7): Executed 19 of 19 SUCCESS (1.708 secs / 0.049 secs)
因此,在管理员运行的cmd窗口中处理第一个,我运行“npm install -g karma-coverage”并获得以下内容:
c:\Users\=myuid=\workspace\SunlightGUI>npm install -g karma-coverage npm http GET https://registry.npmjs.org/karma-coverage npm http 304 https://registry.npmjs.org/karma-coverage npm http GET https://registry.npmjs.org/istanbul npm http GET https://registry.npmjs.org/ibrik npm http GET https://registry.npmjs.org/dateformat npm http 304 https://registry.npmjs.org/ibrik npm http 304 https://registry.npmjs.org/istanbul npm http 304 https://registry.npmjs.org/dateformat npm http GET https://registry.npmjs.org/estraverse npm http GET https://registry.npmjs.org/which npm http GET https://registry.npmjs.org/coffee-script-redux/2.0.0-beta8 npm http GET https://registry.npmjs.org/escodegen npm http GET https://registry.npmjs.org/lodash npm http GET https://registry.npmjs.org/mkdirp npm http GET https://registry.npmjs.org/optimist npm http GET https://registry.npmjs.org/escodegen npm http GET https://registry.npmjs.org/fileset npm http GET https://registry.npmjs.org/resolve npm http GET https://registry.npmjs.org/mkdirp npm http GET https://registry.npmjs.org/esprima npm http GET https://registry.npmjs.org/async npm http GET https://registry.npmjs.org/nopt npm http GET https://registry.npmjs.org/which npm http GET https://registry.npmjs.org/handlebars npm http GET https://registry.npmjs.org/wordwrap npm http GET https://registry.npmjs.org/abbrev npm http GET https://registry.npmjs.org/js-yaml npm http 304 https://registry.npmjs.org/optimist npm http 304 https://registry.npmjs.org/lodash npm http 304 https://registry.npmjs.org/coffee-script-redux/2.0.0-beta8 npm http 304 https://registry.npmjs.org/which npm http 304 https://registry.npmjs.org/estraverse npm http 304 https://registry.npmjs.org/escodegen npm http 304 https://registry.npmjs.org/mkdirp npm http 304 https://registry.npmjs.org/escodegen npm http 304 https://registry.npmjs.org/mkdirp npm http 304 https://registry.npmjs.org/which npm http 304 https://registry.npmjs.org/fileset npm http 304 https://registry.npmjs.org/async npm http 304 https://registry.npmjs.org/esprima npm http 304 https://registry.npmjs.org/handlebars npm http 304 https://registry.npmjs.org/nopt npm http 304 https://registry.npmjs.org/wordwrap npm http GET https://registry.npmjs.org/esutils npm http 304 https://registry.npmjs.org/resolve npm http GET https://registry.npmjs.org/source-map npm http GET https://registry.npmjs.org/minimist npm http 304 https://registry.npmjs.org/js-yaml npm http GET https://registry.npmjs.org/StringScanner npm http GET https://registry.npmjs.org/esmangle npm http GET https://registry.npmjs.org/source-map/0.1.11 npm WARN optional dep failed, continuing cscodegen@git://github.com/michaelficar ra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383 npm http 304 https://registry.npmjs.org/abbrev npm http GET https://registry.npmjs.org/glob npm http GET https://registry.npmjs.org/minimatch npm http GET https://registry.npmjs.org/argparse npm http 304 https://registry.npmjs.org/source-map npm http GET https://registry.npmjs.org/uglify-js npm http 304 https://registry.npmjs.org/source-map/0.1.11 npm http 304 https://registry.npmjs.org/esmangle npm http 304 https://registry.npmjs.org/esutils npm http 304 https://registry.npmjs.org/minimist npm http 304 https://registry.npmjs.org/StringScanner npm http 304 https://registry.npmjs.org/glob npm http 304 https://registry.npmjs.org/minimatch npm http GET https://registry.npmjs.org/amdefine npm http 304 https://registry.npmjs.org/argparse npm http GET https://registry.npmjs.org/lru-cache npm http GET https://registry.npmjs.org/sigmund npm http GET https://registry.npmjs.org/inherits npm http GET https://registry.npmjs.org/escope npm http GET https://registry.npmjs.org/esshorten npm http 304 https://registry.npmjs.org/uglify-js npm http GET https://registry.npmjs.org/underscore npm http GET https://registry.npmjs.org/underscore.string npm http 304 https://registry.npmjs.org/amdefine npm http 304 https://registry.npmjs.org/lru-cache npm http 304 https://registry.npmjs.org/sigmund npm http 304 https://registry.npmjs.org/inherits npm http 304 https://registry.npmjs.org/esshorten npm http 304 https://registry.npmjs.org/underscore.string npm http 304 https://registry.npmjs.org/underscore npm http 304 https://registry.npmjs.org/escope npm ERR! peerinvalid The package karma does not satisfy its siblings' peerDepend encies requirements! npm ERR! peerinvalid Peer karma-chrome-launcher@0.1.3 wants karma@>=0.9.3 npm ERR! peerinvalid Peer karma-coffee-preprocessor@0.2.1 wants karma@>=0.11.14 npm ERR! peerinvalid Peer karma-coverage@0.2.1 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-firefox-launcher@0.1.3 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-html2js-preprocessor@0.1.0 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-ie-launcher@0.1.5 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-jasmine@0.1.5 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-phantomjs-launcher@0.1.4 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-requirejs@0.2.1 wants karma@>=0.9 npm ERR! peerinvalid Peer karma-script-launcher@0.1.0 wants karma@>=0.9 npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "karma-coverage" npm ERR! cwd c:\Users\=myuid=\workspace\SunlightGUI npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! code EPEERINVALID npm ERR! npm ERR! Additional logging details can be found in: npm ERR! c:\Users\=myuid=\workspace\SunlightGUI\npm-debug.log npm ERR! not ok code 0 c:\Users\=myuid=\workspace\SunlightGUI>
这是我的“karma.conf.js”:
module.exports = function(config) {
'use strict';
config.set({
basePath: '../../../..',
frameworks: ['jasmine'],
files: [
...
],
exclude: [
],
plugins:[
'karma-jasmine',
'karma-coverage',
'karma-junit-reporter',
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-ie-launcher'
],
preprocessors: {
"src/main/webapp/js/mylibs/*.js": 'coverage',
"src/main/webapp/js/diag/*.js": 'coverage',
},
coverageReporter: {
type: "lcov",
dir: "target/karma-coverage"
},
junitReporter: {
outputFile: 'target/surefire-reports/TEST-karma.xml'
},
reporters: ['dots', 'junit'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
captureTimeout: 60000,
singleRun: false
});
};
更新
为了完整性,这里是我的“package.json”,但是在我尝试使用“npm install -g”失败后,我删除了我的“node_modules”,只做了“npm install -g karma”。
{
"name": "=myuid=",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "karma.conf.js",
"dependencies": {
"karma-firefox-launcher": "~0.1.0",
"karma-coffee-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma-jasmine": "~0.1.3",
"karma": "~0.10.2",
"karma-coverage": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-requirejs": "~0.1.0",
"karma-chrome-launcher": "~0.1.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "",
"license": "BSD"
}
我想我要重新开始,删除我的“node_modules”然后“npm install -g karma@0.10.2”(我知道的最后一个稳定版本),然后是“karma init”。