a blog for those who code

Friday 13 February 2015

Karma - Spectacular Test Runner for JavaScript

In this post we will discuss about a test runner for JavaScript (Karma).



According to Karma, it is a simple tool that allows you to execute JavaScript code in multiple real browsers. The main purpose of Karma is to make your TDD development easy, fast, and fun.

Karma is not a testing framework, it just launches a HTTP server, and generates the test runner HTML file. It uses Nodejs and SocketIO to allow running your code and tests in multiple browsers.

Install Karma


At first you need to install NodeJS on your machine. Once you have NodeJS installed, you can install Karma by running the following command.

npm install -g karma



Configuration


Now you need to generate the config file. The configuration file can be generated using the following command

karma init 

It will generate a dummy config file (karma.config.js).

PC : http://karma-runner.github.io/0.12/intro/configuration.html

Starting Karma


You can start Karma by running the following command

karma start // it will look for karma.config.js in your current directory

This will start the Karma server on port 9876. You can view the results printed in thr console bu running the karma run command.

PC : http://karma-runner.github.io/0.12/intro/configuration.html

Please Like and Share the Blog, if you find it interesting and helpful.

1 comment:

  1. What's Taking place i'm new to this, I stumbled upon this I've discovered
    It absolutely useful aand it has aided me out loads.
    I am hoping to contribute & aid different customers like
    its aided me. Good job.

    my web blog - italian baby names 2010

    ReplyDelete