There is not much you can do at this moment, generally speaking. The asynchronicity is currently handled by the Control Flow being a queue of promises which are resolved in order one by one. WebDriverJS, which Protractor is based on, though falls under the pressure of the fast evolvement of the JavaScript ecosystem:
JavaScript has evolved in many ways since WebDriverJS was originally
created. Not only did the community standardize the behavior and API
for promises, but promises were added to the language itself. The next
version of JavaScript, ES2017, adds support for async functions,
greatly simplyfing the process of writing and maintaining asynchronous
code. At this point, the benefits of the promise manager no longer
outweigh its costs, so it will soon be deprecated and removed from
WebDriverJS.
And, as of now, in version 4 (should be released soon), there will be no promise manager at all, it was removed from the WebDriverJS API.
The removal of the promise manager means that we should migrate to the native JavaScript features like async/await
- there is a documented migration path already in place. Also, here is Protractor's documentation about using async/await
.
Note that this needs Node >= 8.0 and Jasmine >= 2.7.
I have not personally tried async/await
in Protractor tests and cannot talk about the performance aspect of it, but I expect the promise management part to become faster with async/await
without the overhead of the WebDriver's promise manager.
I guess one other option to make the test execution faster is to turn the Angular-Protractor sync off whenever possible. This though can negatively affect the reliability and cause extra flakiness which can be mitigated with good test habits like having explicit waits.
That said, there are other, more promising (pun intended) ways of speeding up Protractor tests - like test paralellization, avoiding re-opening a browser often etc.
And, that said, keep in mind that end to end tests are slow by definition. Make sure you are not causing reliability issues by trying to solve performance problems.