Reputation: 8276
Could someone explain to me why I need both Protractor and Karma. At a quick glance it seems to me that they are doing the same thing. I understand Karma is for unit tests and Protractor is for e2e test.
I understand both can use (and in most examples using) Jasmine framework to describe the tests.
Upvotes: 6
Views: 2129
Reputation: 691755
A unit test, by definition, tests a single unit of code, in isolation. Testing a controller, in isolation of the services it uses, or testing a service, in isolation of the backend REST server it sends requests to, is a good idea, and makes tests really fast, but having all these tests doesn't guarantee that, when everything is assembled together and really talks to a backend, the application runs as expected.
E2e tests test the application as a whole. They are the equivalent of a human tester sitting in front of a browser and using the application to see if it works as expected. Protractor is a layer on top of Selenium, which allows using a browser programmatically, i.e. write instructions to click on a link, fill in a form, submit it, as a human would do.
Upvotes: 6