I am running my playwright on edge,chrome,safari & firefox browsers using bitbucket pipeline. Some tests are randomly failing due to timeout sometimes on fiefox or chrome even though sufficient wait is available.Once n several attempt, all tests are green as well. Locally also it works fine. Below is the code for waituntil function.
async waitUntil(func, timeout = 1000, pollingRate = 100) {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
clearInterval(interval);
reject(new Error('WaitUntil timed out'));
}, timeout);
const interval = setInterval(() => {
if (!func())
return;
clearTimeout(timer);
clearInterval(interval);
resolve();
}, pollingRate);
});
}
Can anyone suggest something how the test can be stabilized in this case?