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
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.
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
.
I had a face palm moment. karma start
needs to be run in the same directory as your karma.conf.js
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With