Lead Image Photo by Pierre Bamin on Unsplash

Lead Image Photo by Pierre Bamin on Unsplash

Test JavaScript programs with Karma

Karma Chameleon

Article from ADMIN 52/2019
Web developers can test increasingly complex JavaScript applications in multiple browsers with the Karma testing environment.

Thanks to Karma [1], test-driven development should be "easy, fast and fun." The tool launches a web application written in JavaScript and automatically executes the tests specified by the developer in several browsers at the same time while logging the results. The browsers can even run on external devices such as smartphones or tablets, which lets you test your own code under real conditions.

For initial testing, Karma also launches the code, if so required, in a PhantomJS instance running without a GUI (headless operation). Karma also monitors the code and automatically re-executes the stored tests every time a change is made.


Karma itself comprises several plugins, each of which solves a specific task, typically with the use of additional software. Karma also delegates the tests to established test frameworks, such as Jasmine [2], Mocha [3], or QUnit [4], relying on plugins to do so and negating the need for web developers to learn new software. You can also integrate in-house test frameworks as DIY plugins. On the same principle, Karma plugins support continuous integration with Jenkins [5], Travis [6], or Semaphore [7].

After launching, Karma first loads all the plugins and parses its configuration file before launching a web server in the background that serves up the web application to be tested. Karma then runs the browsers against the web server URL.

If required, web developers can also control the web server manually in the browser. Karma detects this action in the

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus