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) {
await test.step(`Validating page value:${issPageValue}`, async () => {
let failCount = 0;
/*
We can't assume that the URL has already changed when we get here, but the point of this
is to help speed up tests, so we want to move on as soon as we can if this passes, but
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);
await expect(async () => {
const currentUrl = this.page.url();
expect(currentUrl).toContain(issPageValue);
}).toPass({
intervals: [1_000],
timeout: 15_000
});
}
}