Hoping to get some feedback on what is the best practice in this situation (Protractor testing framework using page object model with async/await instead of SELENIUM_PROMISE_MANAGER).
Let say I have a function called setUsername
which simply sets the username in a field. I'm wondering is it better practice to use async/await to await the action in the function itself or to return the action. Either way whenever the function is called it will need to be awaited.
option1
this.setUsername = async function (username) {
await usernameInput.sendKeys(username);
}
option2
this.setUsername = function (username) {
return usernameInput.sendKeys(username);
}
Syntax for calling either option
await loginPO.setUsername('admin');
Reasoning: If I go with option1 then I am declaring await twice (in func and when called), which seems unnecessary, but the function behaves more inline with what I expect. If I go with option 2 then await is only used once but it seems wrong to return anything from a function where I only need to set a value and not get anything back.