Problem running Karma test suite

Hi -

I am able to launch my Karma test suite configuration, but no tests will execute. My browser (Chrome) launches, but I see no test results. I can see that Webstorm has located and loaded scripts defined in my Karma configuration files array in the Scripts tool window, but still it is reporting 404 errors.

Run/Debug configuration appears to be set up correctly because there are no errors and the scripts are loaded. Here are my basic configuration file and simple test suite -

// Karma configuration
// Generated on Tue Nov 26 2013 21:06:39 GMT-0800 (PST)

module.exports = function(config) {
  config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '/PROJECTS/IAAS/CloudManagement/cirrus',


    // frameworks to use
    frameworks: ['jasmine', 'requirejs'],


    // list of files / patterns to load in the browser
    files: [
        'app/public/js/lib/require.js',
        'app/public/js/lib/jquery-1.10.2.js',
        'app/public/js/lib/jquery.cookie.js',
        'app/public/js/lib/bootstrap.js',
        'app/public/js/lib/lodash.js',
        'app/public/js/lib/angular/angular.js',
        'app/public/js/lib/angular/angular-ui-router.js',
        'app/public/js/app.js',
        'app/public/js/services/services.js',
        'app/public/js/services/serversdata.js',
        'test/lib/angular/angular-mocks.js',
        'test/spec/controllers/InstanceDataProviderSpec.js'
    ],


    // list of files to exclude
    exclude: [

    ],


    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


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


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


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with `npm install karma-opera-launcher`)
    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
    // - PhantomJS
    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
    browsers: ['Chrome'],


    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,


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

  });

};

//HERE IS MY BASIC TEST SUITE

describe('Controller: MainCtrl', function () {

    beforeEach(module('cirrus'));

    it('should attach a list of awesomeThings to the scope', function () {

        var a = 3;
        var b = 2;

        expect(a).toBe(b);
    });
});

5 comments

When I run the test configuration it says -

config - No config file specified.  and later is reports an Empty test suite. it takes a long time instantiating tests...

but Webstorm is loading my scripts files so that doesn't seem right. The test suite does have an it block.

0

So I've managed to run my test suite now, but debug is not yet fully working. The first issue was that the require.js include was preventing the tests from completing for some reason. I use require in my app, but not for this simple service. Not sure why it would cause the tests to fail.

Then I needed to reference my application like so -

beforeEach(module('cirrus'));

Now I'm continuing to have lots of issues connecting to Chrome. I tend to lose the debug connection frequently. Finally, when I debug I get the following issue on line 39 of Karma jasine adapter.js -

Uncaught TypeError: Cannot read property 'sockets' of undefined

Is anyone else trying to get this working? I'm having a heck of a time getting Karma to work. Thanks.

Peter

0

Hi Peter,

Do you still have the problem?
You're using WebStorm 7.0.2. Right?
If yes, please make sure you're using the latest Karma plugin version 131.562.
Also please attach here a sample project to reproduce the issue, if possible.

Thanks,
Sergey

0

Hi Sergey -

I'm sorry it took me so long to reply. Yes my karma tests are running with the Webstorm plugin. Pretty sweet plugin. Thanks.

Unfortunately, the same configuration and tests are not running from the terminal. Karma launches the browser and files seem to be loaded ok but then no tests are run. Any ideas why this might be the case? Cheers.

Peter

0

No problems.

Finally, when I debug I get the following issue on line 39 of Karma jasine adapter.js -

Uncaught TypeError: Cannot read property 'sockets' of undefined

Looks like you need to update karma-jasmine node package (https://github.com/karma-runner/karma/issues/730).

Please make sure your karma node package is also updated to the latest stable version (which is 0.10.9 at the moment).
To find out karma version you're using open 'Karma Server' tab after running tests.
There should be something like this:

...
INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
...


Please also update your WebStorm installation to 7.0.3 (it contains a few fixes for Karma integration).
After that please try again to run tests. Will the problem persist?

Unfortunately, the same configuration and tests are not running from the terminal. Karma launches the browser and files seem to be loaded ok but then no tests are run. Any ideas why this might be the case?


If tests aren't running from the terminal, then you have configured Karma incorrectly.
Please attach here a sample that reproduces the problem. It will help to find out the cause.

See also a similar discussion: http://devnet.jetbrains.com/message/5506766

0

Please sign in to leave a comment.