9

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,
  });
};
lin
  • 17,956
  • 4
  • 59
  • 83
Candres
  • 385
  • 2
  • 5
  • 18

2 Answers2

10

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'],
lin
  • 17,956
  • 4
  • 59
  • 83
  • 1
    the 'progress' reporter was missing in my configuration (initially created by yeoman a long time ago). so thanks for the hint. – smoebody Feb 21 '15 at 12:59
  • 1
    Well, my test is there. But I still get the message. PhantomJS 1.9.8 (Linux): Executed 1 of 1 (1 FAILED) ERROR (0.051 secs / 0.015 secs) Warning: Task "karma:unit" failed. Use --force to continue. – Stephane Apr 11 '15 at 16:01
  • 1
    I have one successful test case. still it shows the same warning message. – Ankit Tanna Jan 08 '16 at 06:09
  • This answer does not solve the problem. I am having the same problem. – Michelangelo Aug 02 '16 at 11:29
  • @Mikey, so you have an other problem. See the question. His problem were without any "test". `Executed 0 of 0 ERROR`, It does solve his problem. – lin Aug 03 '16 at 10:57
  • @lin It is so strange. I have one test and if it passes it does not give the error. If it fails it gives the `Warning: Task "karma:unit" failed. Use --force to continue.` This is so strange, I mean the task did not fail, the test failed! – Michelangelo Aug 03 '16 at 12:28
4

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

Then sudo npm install karma