我在执行 grunt karma:unit 时遇到问题,任务已完成,但抛出此内容:
.......
DEBUG [web-server]: serving (cached): C:/project/yo
/test/spec/services/lists.js
Firefox 32.0.0 (Windows 7): Executed 0 of 0 ERROR (0.027 secs / 0 secs)
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Process Firefox exited with code 0
DEBUG [temp-dir]: Cleaning temp dir C:\Users\developer\AppData\Local\Temp\karma-14
854612
Warning: Task "karma:unit" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2014-10-16 21:25:51 UTC)
karma:unit 4.1s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100%
Total 4.1s
测试目录包含测试空,例如:
'use strict';
describe('Service: lists', function () {
});
我不明白为什么结果如下:警告:任务"业力:单位"失败。使用--force继续。。
我的karma.conf.js文件包含:
module.exports = function(config) {
'use strict';
config.set({
autoWatch: true,
basePath: '../',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'app/bower_components/jquery/dist/jquery.js',
'app/bower_components/angular/angular.js',
'app/bower_components/json3/lib/json3.js',
'app/bower_components/bootstrap/dist/js/bootstrap.js',
'app/bower_components/jquery-ui/jquery-ui.js',
'app/bower_components/angular-animate/angular-animate.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-sanitize/angular-sanitize.js',
'app/bower_components/angular-touch/angular-touch.js',
'app/bower_components/lodash/dist/lodash.compat.js',
'app/bower_components/restangular/dist/restangular.js',
'app/bower_components/angular-ui-router/release/angular-ui-router.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'app/bower_components/angular-translate/angular-translate.js',
'app/bower_components/angular-moment/angular-moment.js',
'app/bower_components/angular-ui-router/release/angular-ui-router.js',
'app/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
'app/scripts/**/*.js',
'test/spec/**/*.js'
],
exclude: [],
port: 8080,
browsers: [
'Firefox'
],
plugins: [
'karma-firefox-launcher',
'karma-jasmine'
],
singleRun: false,
colors: true,
logLevel: config.LOG_DEBUG,
});
};
答案 0 :(得分:10)
Karma需要至少一次测试才能使其成功/成功。看看你的调试输出:
Firefox 32.0.0 (Windows 7): Executed 0 of 0 ERROR (0.027 secs / 0 secs)
一旦只添加一个测试,就会有效:
Firefox 32.0.0 (Windows 7): Executed 1 of 1 SUCCESS (0.031 secs / 0 secs)
如何在运行测试时在控制台输出中显示控制台日志和错误?
请将progress
param添加到您的karma配置文件中。
您可以在此处的文档中阅读相关内容:http://karma-runner.github.io/0.8/config/configuration-file.html
reporters: ['progress'],
答案 1 :(得分:3)
您可以尝试删除:/workspace/node_modules/.karma.DELETE/ 或/ workspace / node_modules / karma
然后sudo npm install karma