Javascript - Karma (Test runner)

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Javascript - Test

1 - About

Karma is a javascript test runner that permit to execute test code in multiple real browsers via phantomJs.

Karma is not a testing framework, nor an assertion library. Karma just launches an HTTP server, and generates the test reports on how successful the tests were.

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected with another test runner framework.

Advertising

3 - Testing framework

There are already plugins for most of the common testing frameworks:

4 - Installation

  • Installation
npm install # if Karma and all the required plugins are already defined in package.json
npm install --save-dev karma
npm install --save-dev <required_karma_plugin> <another_required_karma_plugin>
  • Configuration
#For macOS and Linux:
./node_modules/karma/bin/karma init
#For Windows:
npm install -g karma-cli
karma init

5 - Conf

Tests are run according to a karma.conf.js configuration file which is generated in the interactive mode.

6 - Documentation / Reference

Advertising
web/javascript/test/karma.txt · Last modified: 2019/02/16 17:40 by gerardnico