Currently, I am in the process of creating some protractor tests that look like this:
import { browser, element, by, ExpectedConditions } from 'protractor';
export class SomePage {
private elements: any = {};
navigateToUpdate(name: string) {
return browser.get(`/pages/${name}`)
.then(() => browser.waitForAngular())
.then(() => browser.wait(this.statusIsPresent))
.then(() => this.initElements());
}
private initElements(): Promise<void> {
// Implement functionality here
return Promise.resolve();
}
private get statusIsPresent(): Function {
return ExpectedConditions.presenceOf(element(by.id('status')));
}
}
After incorporating the wait()
function, I noticed that navigateToUpdate()
now returns
Promise<Promise<void>>
. This is causing confusion for me as to why it behaves this way, and whether or not it could potentially lead to bugs that may be difficult to identify.
Despite the return type of browser.wait()
, shouldn't
Promise.resolve().then(() => browser.wait()).then(() => something())
simply return the result of something()
, rather than a Promise containing the result of something()
?