Using Protractor for End-to-End tests
As we saw earlier with Karma, we can write unit tests that will make sure that our code in the controllers is working well; however, it would fall short if you wanted to run automated User Acceptance Tests (UAT) or run tests that simulate user-driven interactions with the browser. For running such tests, we'll need to use another new tool called Protractor.
Protractor replaces the earlier AngularJS scenarios as the default End-to-End testing framework for testing AngularJS apps.
Protractor runs on WebDriver.js
, which in turn makes use of the
Selenium Server. Selenium is one of the most popular browser-automation tools. In this section, we will see how to set up a standalone instance of Selenium Server, install Protractor, and run a default set of End-to-End tests with it.
Let's first install Protractor by running the following command in the terminal:
sudo npm install –g protractor
This will install Protractor globally.