flexysnap 0.5.0 → 0.5.1

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.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Flexible visual snapshot testing for Playwright, built for e-commerce.",
5
5
  "keywords": [
6
6
  "playwright",
package/src/index.js CHANGED
@@ -10,7 +10,8 @@ export {
10
10
  scrollToTopOfElement,
11
11
  setClosePopups,
12
12
  logTimestamp,
13
- setBaseUrl
13
+ setBaseUrl,
14
+ setCacheableUrlPattern
14
15
  } from './testUtils.js';
15
16
 
16
17
  export {
package/src/testUtils.js CHANGED
@@ -41,6 +41,12 @@ function setBaseUrl(url) {
41
41
  baseUrl = url;
42
42
  }
43
43
 
44
+ let cacheableUrlPatterns = ['/wp-content/', '/wp-includes/']
45
+
46
+ function setCacheableUrlPattern(pattern) {
47
+ cacheableUrlPatterns.push(pattern)
48
+ }
49
+
44
50
  test.beforeEach(async ({ context }) => {
45
51
  startTimer();
46
52
  logTimestamp('Test execution started');
@@ -48,6 +54,12 @@ test.beforeEach(async ({ context }) => {
48
54
  const req = route.request();
49
55
  const url = new URL(req.url());
50
56
  const path = url.pathname.toLowerCase();
57
+
58
+ for (let pattern of cacheableUrlPatterns) {
59
+ if (path.includes(pattern))
60
+ return route.continue();
61
+ }
62
+
51
63
  if (req.method() !== 'GET' || path.includes('/wp-content/') || !url.href.includes(baseUrl)) {
52
64
  return route.continue();
53
65
  }
@@ -240,5 +252,6 @@ export {
240
252
  setClosePopups,
241
253
  callClosePopups,
242
254
  logTimestamp,
243
- setBaseUrl
255
+ setBaseUrl,
256
+ setCacheableUrlPattern
244
257
  };