Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular testing techniques Jasmine vs karma vs protractor in Angular 2?

Tags:

angular

I am new in angular testing. Can anyone tell me about the difference between these above 3 techniques?

like image 677
Aman Jain Avatar asked Sep 13 '17 12:09

Aman Jain


People also ask

What is difference between Jasmine and Protractor?

Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, Node. js projects, or anywhere that JavaScript can run; Protractor: End-to-end test framework for Angular and AngularJS applications.

What is difference between Jasmine and karma?

Jasmine can be classified as a tool in the "Javascript Testing Framework" category, while Karma is grouped under "Browser Testing". "Can also be used for tdd " is the primary reason why developers consider Jasmine over the competitors, whereas "Test Runner" was stated as the key factor in picking Karma.

What is the role of Jasmine and karma in Angular testing?

Jasmine is a behavior-driven development framework for testing JavaScript code that plays very well with Karma. Similar to Karma, it's also the recommended testing framework within the Angular documentation as it's setup for you with the Angular CLI. Jasmine is also dependency free and doesn't require a DOM.

What is karma and Protractor?

What's the difference between Karma and Protractor? When do I use which? Karma is a great tool for unit testing, and Protractor is intended for end-to-end or integration testing. This means that small tests for the logic of your individual controllers, directives, and services should be run using Karma.


2 Answers

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.

Karma is essentially a tool for testing which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

Jasmine and Karma are usually used together to perform Unit testing or integration testing.

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would without depending on other tools for performing the same. Check out how it works here.

References:

Jasmine Documentation

Karma - How it works?

Protractor

like image 165
Sanju Avatar answered Sep 16 '22 16:09

Sanju


Karma is test runner like grunt and gulp Jasmine is a BDD framework for testing

You can write expectations i.e. tests in jasmine and run it using Karma.

Protractor does this both the things for you.

like image 27
RVCoder Avatar answered Sep 17 '22 16:09

RVCoder