Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma not running unit tests due to "No captured browser" message

I'm trying to set up Karma to run AngularJS unit tests using Jasmine, but I can't get the tests to run. I'm sure I'm overlooking something simple. I'm running this on a Windows 7 machine with Node.js installed and karma installed via npm.

My directory structure looks like this:

  • js/app/ - contains controllers, app, etc
  • js/config/ - contains karma.conf.js
  • js/lib/ - contains angular
  • js/test/ - contains jasmine specs

I'm starting a command prompt in the js directory and running this command:

karma start config/karma.conf.js

That causes Chrome to run on port 9876, but whenever I change any watched files and check the Karma output, I see this info message:

No captured browser, open http://localhost:9876/

Here's my config file:

module.exports = function(config) {   config.set({     basePath: '../',     frameworks: ['jasmine'],     files: [       'lib/angular.js',       'app/**/*.js',       'test/**/*.js'     ],     exclude: [     ],     reporters: ['progress'],     port: 9876,     colors: true,     logLevel: config.LOG_INFO,     autoWatch: true,     browsers: ['Chrome'],     captureTimeout: 60000,     singleRun: false   }); }; 

I'm using Angular 1.2.10 and Karma 0.10.9

like image 780
levelnis Avatar asked Feb 02 '14 17:02

levelnis


People also ask

Is Karma used for unit testing?

To carry out unit testing on an application, the front-ends built with these front-end frameworks or even those built without the frameworks, certain automation testing tools like Karma, mocha, Jasmine, jest, enzyme, etc., are used.


2 Answers

I just had the same issue in a different setup (Linux, QUnit, Firefox), though. The problem disappeared after I killed all karma processes and did a fresh karma start.

like image 108
user1460043 Avatar answered Sep 29 '22 20:09

user1460043


I had a face palm moment. karma start needs to be run in the same directory as your karma.conf.js file.

like image 25
AlignedDev Avatar answered Sep 29 '22 20:09

AlignedDev