gpt4 book ai didi

angularjs - AngularJS 项目中的 Grunt Karma 单元任务失败

转载 作者:行者123 更新时间:2023-12-02 19:20:41 26 4
gpt4 key购买 nike

我在执行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 () {

});

我不明白为什么结果是:警告:任务“karma:unit”失败。使用 --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,
});
};

最佳答案

Karma 需要至少 1 次测试才能使其发挥作用/成功。查看调试输出:

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)
<小时/>

How to make console log and error's displayed in console output while running a test?

请将 progress 参数添加到您的 karma 配置文件中。

您可以在此处的文档中阅读相关内容:http://karma-runner.github.io/0.8/config/configuration-file.html

reporters: ['progress'],

关于angularjs - AngularJS 项目中的 Grunt Karma 单元任务失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26414271/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com