Well, if this is still relevant, I started working with tests again, and this time I immediately found a solution.
These assistants open the bridge between protractor.promise.Promiseand the native Promise.
const toNativePromise = <T = void>(p: protractor.promise.Promise<T>): Promise<T> => {
return new Promise((res, rej) => {
p.then(res).catch(rej)
})
}
const toProtractorPromise = <T = void>(p: Promise<T>): protractor.promise.Promise<T> => {
var deferred = protractor.promise.defer<T>();
var promise = deferred.promise;
return promise
}
Anyway, to solve your original problem, you can write something like this:
const myFilter = async(e: ElementFinder): Promise<boolean> => { ... }
const myFilterForProtractor = (e) => toProtractorPromise(myFilter(e))
source
share