MCPcopy
hub / github.com/ampproject/amphtml / verifySelectorsInvisible

Function verifySelectorsInvisible

build-system/tasks/visual-diff/verifiers.js:25–49  ·  view source on GitHub ↗

* Verifies that all CSS elements are as expected before taking a snapshot. * * @param {!puppeteer.Page} page a Puppeteer control browser tab/page. * @param {string} testName the full name of the test. * @param {!Array } selectors Array of CSS selector that must eventually * be remove

(
  page,
  testName,
  selectors,
  timeoutMillis = CSS_SELECTOR_TIMEOUT_MS
)

Source from the content-addressed store, hash-verified

23 * @throws {Error} an encountered error.
24 */
25async function verifySelectorsInvisible(
26 page,
27 testName,
28 selectors,
29 timeoutMillis = CSS_SELECTOR_TIMEOUT_MS
30) {
31 log(
32 'verbose',
33 'Waiting for invisibility of all:',
34 cyan(selectors.join(', '))
35 );
36 try {
37 await Promise.all(
38 selectors.map((selector) =>
39 waitForElementVisibility(page, selector, {hidden: true}, timeoutMillis)
40 )
41 );
42 } catch (e) {
43 throw new Error(
44 `${cyan(testName)} | An element with the CSS ` +
45 `selector ${cyan(e.message)} is still visible after ` +
46 `${CSS_SELECTOR_TIMEOUT_MS} ms`
47 );
48 }
49}
50
51/**
52 * Verifies that all CSS elements are as expected before taking a snapshot.

Callers 7

snapshotWebpagesFunction · 0.85
amp-selector.jsFile · 0.85
amp-list.amp.jsFile · 0.85

Calls 3

cyanFunction · 0.85
waitForElementVisibilityFunction · 0.85
logFunction · 0.70

Tested by

no test coverage detected