Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tests with Karma not finishing

I have been trying to run some tests with karma but have not been able to get it to work. After trying to get it to work with my application, I tried running it with the most simple possible test, and yet, it still does not finish.

Here is my karma.conf.js file:

    // Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      // 'app/bower_components/angular/angular.js',
      // // 'app/bower_components/angular/angular-mocks.js',
      // 'app/scripts/*.js',
      // 'app/scripts/controllers/main.js',
      // // 'test/mock/**/*.js',
      // 'test/spec/**/*.js',
      // // 'app/scripts/**/*.js,'
      'testing.js'
    ],

    // list of files / patterns to exclude
    exclude: ['angular-scenario.js'],

    // web server port
    port: 8080,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};

and here is the testing.js file :

describe("hello", function(){
    it("Should fail automatically", function(){
        expect(false).toBe(true)
    });
});

The result I get without fail is:

$ karma start karma.conf.js
INFO [karma]: Karma v0.10.9 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 30.0.1599 (Mac OS X 10.7.5)]: Connected on socket dGANukHhgkPC3YyhyUrU
INFO [Chrome 30.0.1599 (Mac OS X 10.7.5)]: Connected on socket HC8iGMv-VmeYX2UAyUrV

It never seems to go on and tell me how many of my tests succeeded or not.

Thanks for all of the help. Hopefully I will have some hair left at the end of this, haha.

like image 393
Pytth Avatar asked Jan 21 '14 03:01

Pytth


1 Answers

This is the expected behaviour.

single_run : true means run the tests once and exit.

single_run : false means don't exit (this is not obvious).

autowatch : true means trigger running tests when a file changes.

If you have both autowatch and single_run set to false (like you do), then running

karma start

will just have karma initialize and wait for something to trigger it to run.

In order to trigger running the tests you need to open a new console and do

karma run

(Or set one of the above mentioned flags to 'true')

like image 111
Cristian Diaconescu Avatar answered Sep 19 '22 10:09

Cristian Diaconescu