flexysnap 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexysnap",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Flexible visual snapshot testing for Playwright, built for e-commerce.",
5
5
  "keywords": [
6
6
  "playwright",
package/src/testUtils.js CHANGED
@@ -9,10 +9,10 @@ async function callClosePopups(page) {
9
9
  async function gotoWithRetry(page, url) {
10
10
  try {
11
11
  logTimestamp('Loading ' + url);
12
- await page.goto(url, { timeout: 30_000, waitUntil: "domcontentloaded" });
12
+ await page.goto(url, { timeout: 30_000, waitUntil: "commit" });
13
13
  } catch (firstError) {
14
14
  logTimestamp('Retry loading ' + url);
15
- await page.goto(url, { timeout: 30_000, waitUntil: "domcontentloaded" });
15
+ await page.goto(url, { timeout: 30_000, waitUntil: "commit" });
16
16
  }
17
17
  await waitForCompleteLoad(page)
18
18
  }
@@ -287,6 +287,8 @@ function compareTexts(baselineTexts, currentTexts, options) {
287
287
  }
288
288
 
289
289
  function compareElements(baselineElement, currentElement, options) {
290
+ currentElement.differences = currentElement.differences || [];
291
+
290
292
  if (baselineElement.histogram && currentElement.histogram) {
291
293
  const dh = histogramDiff(baselineElement.histogram, currentElement.histogram);
292
294
  if (dh > 15) {
@@ -300,11 +302,11 @@ function compareElements(baselineElement, currentElement, options) {
300
302
  if (baselineElement.texts.length > 0 || currentElement.texts.length > 0) {
301
303
  compareTexts(baselineElement.texts, currentElement.texts, options);
302
304
  } else {
303
- currentElement.differences = compareBoundingBoxes(
305
+ currentElement.differences = currentElement.differences.concat(compareBoundingBoxes(
304
306
  baselineElement.boundingRect,
305
307
  currentElement.boundingRect,
306
308
  options
307
- );
309
+ ));
308
310
  }
309
311
  }
310
312