Async Await
When you are searching for an element with Protractor you are returning a promise that should be fulfilled before moving on to the next step. Lets say you are wanting to debug your tests using console.log statements.
console.log($('.someclass').getText());
This would return a promise object for that elements text. But that is not very readable when you need it. Alternatively you could wrap that into a then() but that involve a lot more text as well. With ES6 there is the idea of async functions. In order to make this work from out test we have to make the function nested in the "it" block async. After that we can use await to allow the promise to complete and then we can continue processing the text.
it('should give us text', async function() {
console.log(await $('.someclass').getText());
});
Now if you are trying this at home you will also need some extra libraries added.
Install Babel and Plugins.
$ npm install babel-core babel-plugin-transform-async-to-generator
Add require to protractor-conf.js
require('babel-core/register');
Create a .babelrc file
{
"plugins": ["transform-async-to-generator"]
}