MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / waitCurrentPathEquals

Method waitCurrentPathEquals

lib/helper/Playwright.js:3472–3496  ·  view source on GitHub ↗

* {{> waitCurrentPathEquals }}

(path, sec = null)

Source from the content-addressed store, hash-verified

3470 * {{> waitCurrentPathEquals }}
3471 */
3472 async waitCurrentPathEquals(path, sec = null) {
3473 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3474 const normalizedPath = normalizePath(path)
3475
3476 try {
3477 await this.page.waitForFunction(
3478 expectedPath => {
3479 const actualPath = window.location.pathname
3480 const normalizePath = p => (p === '' || p === '/' ? '/' : p.replace(/\/+/g, '/').replace(/\/$/, '') || '/')
3481 return normalizePath(actualPath) === expectedPath
3482 },
3483 normalizedPath,
3484 { timeout: waitTimeout },
3485 )
3486 } catch (e) {
3487 const currentUrl = await this._getPageUrl()
3488 const baseUrl = this.options.url || 'http://localhost'
3489 const actualPath = new URL(currentUrl, baseUrl).pathname
3490 if (/Timeout/i.test(e.message)) {
3491 throw new Error(`expected path to be ${normalizedPath}, but found ${normalizePath(actualPath)}`)
3492 } else {
3493 throw e
3494 }
3495 }
3496 }
3497
3498 /**
3499 * {{> waitForText }}

Callers

nothing calls this directly

Calls 3

_getPageUrlMethod · 0.95
normalizePathFunction · 0.90
waitForFunctionMethod · 0.45

Tested by

no test coverage detected