MCPcopy
hub / github.com/freshframework/fresh / waitForText

Function waitForText

packages/fresh/tests/test_utils.tsx:295–321  ·  view source on GitHub ↗
(
  page: Page,
  selector: string,
  text: string,
)

Source from the content-addressed store, hash-verified

293}
294
295export async function waitForText(
296 page: Page,
297 selector: string,
298 text: string,
299) {
300 await page.waitForSelector(selector);
301 try {
302 await page.waitForFunction(
303 (sel: string, value: string) => {
304 const el = document.querySelector(sel);
305 if (el === null) return false;
306 return el.textContent === value;
307 },
308 { args: [selector, String(text)] },
309 );
310 } catch (err) {
311 const body = await page.content();
312 // deno-lint-ignore no-explicit-any
313 const pretty = prettyDom(parseHtml(body) as any);
314
315 // deno-lint-ignore no-console
316 console.log(
317 `Text "${text}" not found on selector "${selector}" in html:\n\n${pretty}`,
318 );
319 throw err;
320 }
321}
322
323export async function waitFor(
324 fn: () => Promise<unknown> | unknown,

Callers 6

init_test.tsFile · 0.90
partials_test.tsxFile · 0.90
islands_test.tsxFile · 0.90
head_test.tsxFile · 0.90
build_test.tsFile · 0.90
dev_server_test.tsFile · 0.90

Calls 2

prettyDomFunction · 0.85
parseHtmlFunction · 0.85

Tested by

no test coverage detected