Use expect.toPass instead of timeout/while loop
This commit is contained in:
parent
e3428b0bf9
commit
a974e53bc8
1 changed files with 6 additions and 19 deletions
|
|
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue