Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between karma and phantomJS

I know that Karma is a test runner for JS Unit Testing frameworks like Jasmine or Mocha. And PhantomJS provides headless browser for running Jasmine or Mocha Tests.

But, what is the difference between Karma and PhantomJS? Are they two competing tools, or do I use PhantomJS on top of Karma to run my unit tests without a browser?

like image 882
Rohan Avatar asked Dec 22 '15 19:12

Rohan


People also ask

What is karma PhantomJS?

The karma-phantomjs-launcher enables the karma test runner to launch and interact with PhantomJS. Use NPM to install the karma-phantomjs-launcher package as a dev dependency by executing the following command in the root of the project: npm install karma-phantomjs-launcher --save-dev.

What is PhantomJS used for?

PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.


1 Answers

PhantomJS has nothing to do with testing. In the unit testing scope it would become one of the target browsers.

PhantomJS allows you to run unit tests in a browser when a desktop environment doesn't exist.

Karma is a runner that provides the finished reports on how successful the tests where.

Jasmine is the library used to write unit tests.

So to clarify

Jasmine unit tests are run by Karma inside the browser PhantomJS.

like image 188
Reactgular Avatar answered Sep 28 '22 11:09

Reactgular