Question

I am new to Karma. When i run:

karma start myconfigfile.js

Karma is starting up with chrome, but it hangs at karma starting and nothing more is happening. However i can go into http://localhost:9876/debug.html and can see that tests have been running in console. My test is inside vendor/Jasmine/spec/PlayerSpec.js.

Is this the correct way of using karma for testing or are there some more UI-frendly ways?

Because I can see that karma window should look like this.

Have anyone had same problem?

here is my config file:

module.exports = function(config) {
  config.set({
    basePath: '/',
    frameworks: ['jasmine'],
    files: [
        'nodejs/node_modules/karma-jasmine/lib/jasmine.js',
        'nodejs/node_modules/karma-jasmine/lib/adapter.js',
        'nodejs/node_modules/requirejs/*.js',
        'vendor/Jasmine/spec/PlayerSpec.js',
        'angular/angular.min.js',
        'angular/angular-mocks.js'

    ],
    exclude: [

    ],
    preprocessors: {

    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};
Était-ce utile?

La solution

Karma is made of two main components: a server and a runner.

The first one prepare the test environment and spawn the browsers, but is the second one that starts the tests.

To start the server you have to run karma start, while for the second one you have to start in a second shell karma run <configuration_file_path> - try it and see the tests running.

If you want to start it automatically, just change this line in your config file:

  singleRun: true // => is was false

At this point Karma will setup the server, run the tests and shutdown when completed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top