Protractor is known mostly for end 2 end testing, as an open source automation framework that was designed by Google for Angularjs applications.
Protractor is an end to end framework that tests your application just like a user would. You can build the tests around your tests cases. What happens if an user clicks a specific button? What is the next step? What happens if a user adds a negative value into a field? Is an error shown? Does it goes to the next step ? If you have the tests cases, or the business logic in a document, you can write tests around that. The recommended way when coding end to end tests, is to write tests around the functionality.
Protractor it was released in July 2013 as a prototype for Angular JS testing framework. Later it evolved in what we currently know as protractor.
Protractor is a wrapper build around Selenium with webdriverio.
It supports angular specific locators (for example repeaters id’s, ng-click, ng-if etc)
It supports PageObjects (Page object represents an Object Pattern Design) – helps on writing more clean and readable code.
It can use the same Framework integration for unit and end to end tests.
It supports fast development (you do not need to use sleep or wait, because it communicates with Angular directly)
It is based on Angular’s concepts, therefore it’s quite easy to test your own code.
Protractor (just like angular) works with promises and expects.
A promise in Protractor works just like a queue control. Of like a control flow if you will.
Expects – is something that protractor needs to get.
Expect “title” to be “Protractor tests”. But first, you have to get the element where the title is stored, then read the title.
Antother cleaner option to write this, can be as follows:
var myElement = element(by.tagName('h2'));
You can easily improve the development flow using runners and compilers. For example grunt. You can set grunt in order to run everytime you save the spec file.
For protractor you can use Jasmine or Mocha, Cucumber to write tests for BDD Behaviour Driven Development.
There is an integrations (not recommended) for headless testing with PhantomJS headless browser.
You can also use Karma for unit tests.