q library has this neat feature to resolve and spread multiple promises into separate arguments:
If you have a promise for an array, you can use sprea
TL;DR Apparently, it's not entirely safe to replace protractor.promise with q. For instance, I've got a hanging test run once I've decided to extend ElementArrayFinder:
Old answer:
Here is what I've done to solve it.
I've replaced protractor.promise with q on the fly (not sure if it's actually safe to do):
onPrepare: {
protractor.promise = require("q");
},
But, nothing broke so far and now I'm able to use spread() and other syntactic sugar provided by q through protractor.promise:
toBeActive: function() {
return {
compare: function(elm) {
return {
pass: protractor.promise.all([
elm.getId(),
browser.driver.switchTo().activeElement().getId()
]).spread(function (currentElementID, activeElementID) {
return jasmine.matchersUtil.equals(currentElementID, activeElementID);
})
};
}
};
}
Relevant github thread: protractor.promise to use q.