JavaScript

Simplify your Protractor tests using Generator functions

Posted on by  
Auke Speksnijder

Writing protractor tests can be quite difficult, because of all the asynchronous calls you have to deal with. Even promise-chaining does not help when your tests become longer and more complex. With Javascript generator functions it is possible to simplify your tests.

Let’s say we have a todo-app created in AngularJS with two pages: a page with a list of todos and a page where a user can create a todo-item. We have two page objects created that can communicate with the pages in our Protractor tests. This is an example of an actual testcase with the use of promise chaining:

As you can see, the testcode is much easier to understand when the generator method is used.

Continue reading →

shadow-left