Use expect.toPass instead of timeout/while loop

This commit is contained in:
Alex Humphries 2025-03-10 09:57:55 -04:00
parent e3428b0bf9
commit a974e53bc8

View file

@ -116,25 +116,12 @@ export class BasePage {
} }
async validateURL(issPageValue: string) { async validateURL(issPageValue: string) {
await expect(async () => {
await test.step(`Validating page value:${issPageValue}`, async () => { const currentUrl = this.page.url();
let failCount = 0; expect(currentUrl).toContain(issPageValue);
/* }).toPass({
We can't assume that the URL has already changed when we get here, but the point of this intervals: [1_000],
is to help speed up tests, so we want to move on as soon as we can if this passes, but timeout: 15_000
without waiting too long if it fails
*/
while(failCount < 15) {
const currentUrl = this.page.url();
console.log(`Current URL: ${currentUrl}`)
if(currentUrl.includes(issPageValue))
break;
else {
failCount++;
}
await this.page.waitForTimeout(1000);
}
expect(failCount).not.toEqual(15);
}); });
} }
} }