MCPcopy
hub / github.com/codeceptjs/CodeceptJS / waitUrlEquals

Method waitUrlEquals

lib/helper/Puppeteer.js:2528–2549  ·  view source on GitHub ↗

* {{> waitUrlEquals }}

(urlPart, sec = null)

Source from the content-addressed store, hash-verified

2526 * {{> waitUrlEquals }}
2527 */
2528 async waitUrlEquals(urlPart, sec = null) {
2529 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2530 const expectedUrl = resolveUrl(urlPart, this.options.url)
2531
2532 return this.page
2533 .waitForFunction(
2534 url => {
2535 const currUrl = decodeURIComponent(window.location.href)
2536 return currUrl === url
2537 },
2538 { timeout: waitTimeout },
2539 expectedUrl,
2540 )
2541 .catch(async e => {
2542 const currUrl = await this._getPageUrl()
2543 if (/Waiting failed/i.test(e.message) || /failed: timeout/i.test(e.message)) {
2544 throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`)
2545 } else {
2546 throw e
2547 }
2548 })
2549 }
2550
2551 /**
2552 * {{> waitCurrentPathEquals }}

Callers 4

testsFunction · 0.45

Calls 3

_getPageUrlMethod · 0.95
resolveUrlFunction · 0.90
waitForFunctionMethod · 0.45

Tested by

no test coverage detected