What is the difference between karma and phantom

I know that Karma is the test leader for JS Unit Testing such as Jasmine or Mocha. And PhantomJS provides a mute browser to run Jasmine or Mocha tests.

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

+5
source share
2 answers

PhantomJS has nothing to do with testing. In the field of unit testing, it will become one of the targeted browsers.

PhantomJS allows you to run unit tests in a browser when the desktop environment does not exist.

Karma is a runner who provides ready-made reports on how successful tests are, where.

Jasmine is a library used to write unit tests.

So, to clarify

Jasmine modules are executed by Karma inside the PhantomJS browser.

+25
source

It seems that you have already answered your question somewhat, but I will talk about what you mentioned.

Karma is a test framework that is largely agnostic for language tests. It has a rich ecosystem of plugins that lets you pretty much customize how and when your tests run.

To test Javascript, we often need to test against the implementation of the DOM. There are many plugins that allow you to connect to various browsers, such as karma chrome. These plugins load the required browser and run your tests against the browser.

However, there are times when you want to run without a physical browser installed in the target test field. this is where PhantomJS comes in. This is a headless browser that can be launched without being installed on the target machine. He cannot replace karma. If you want to describe him as a "competitor", he will be a competitor to IE, Firefox, Chrome and Safari.

+4
source

Source: https://habr.com/ru/post/1238981/


All Articles