I am trying Karma for the first time, and after several hours I still can't get it to work.
When I run the test by typing karma start karma.conf.js
in the terminal, the browser window opens and displays the following (I have also tried with Chrome with the same result):
This is the terminal output:
29 07 2015 16:27:12.835:INFO [karma]: Karma v0.13.3 server started at http://localhost:9876/
29 07 2015 16:27:12.852:INFO [launcher]: Starting browser Firefox
29 07 2015 16:27:15.866:INFO [Firefox 33.0.0 (Windows 7 0.0.0)]: Connected on socket HA1RSN-QsWuAO7NIAAAA with id 26755366
My karma.conf.js file is located at the root of my Node.js project and looks like this:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'tests/unit/test.js'
],
exclude: [],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Firefox'],
singleRun: false
})
}
My test.js file looks like this (example test from a book, my actual tests will the Angular.js tests):
describe("First Test", function () {
var counter;
beforeEach(function () {
counter = 0;
});
it("increments value", function () {
counter++;
expect(counter).toEqual(1);
});
it("decrements value", function () {
counter--;
expect(counter).toEqual(0);
});
});
I'm using Node.js version 0.12.05.
I appreciate any help as I feel really lost here.
The server can be stopped using the karma stop command.
The karma. conf. js file is a partial Karma configuration file. The CLI constructs the full runtime configuration in memory, based on application structure specified in the angular. json file, supplemented by karma.
Most of the framework adapters, reporters, preprocessors and launchers needs to be loaded as plugins. The Karma configuration file can be written in JavaScript or CoffeeScript and is loaded as a regular Node. js module. Within the configuration file, the configuration code is put together by setting module.
You need to trigger a test run, if you want it to execute. There are two ways to do this
karma run karma.conf.js
in a second terminal window in the same working directorysingleRun
to true
, this way it will start, execute the test and then exit.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