当前位置: 动力学知识库 > 问答 > 编程问答 >

Grunt Karma unit task fail with AngularJS project

问题描述:

I have a problem executing grunt karma:unit, the task finished but throw this:

.......

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

The test directory contains the test empty, for example:

'use strict';

describe('Service: lists', function () {

});

I don't understand why the result is: Warning: Task "karma:unit" failed. Use --force to continue..

My karma.conf.js file contains:

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 needs at least 1 test to make it work/succeed. Take a look in your debug output:

Firefox 32.0.0 (Windows 7): Executed 0 of 0 ERROR (0.027 secs / 0 secs)

Once you add just one test, it will work:

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?

Please add the progress param into you karma configuration file.

You can read about this in documentation here: http://karma-runner.github.io/0.8/config/configuration-file.html

reporters: ['progress'],
网友答案:

You can try to remove : /workspace/node_modules/.karma.DELETE/ or /workspace/node_modules/karma

Then sudo npm install karma

分享给朋友:
您可能感兴趣的文章:
随机阅读: