@percy/core 1.28.1 → 1.28.2-beta.0

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/dist/config.js CHANGED
@@ -199,6 +199,9 @@ export const configSchema = {
199
199
  type: 'boolean',
200
200
  default: false
201
201
  },
202
+ captureSrcset: {
203
+ type: 'boolean'
204
+ },
202
205
  requestHeaders: {
203
206
  type: 'object',
204
207
  normalize: false,
@@ -346,6 +349,9 @@ export const snapshotSchema = {
346
349
  captureMockedServiceWorker: {
347
350
  $ref: '/config/discovery#/properties/captureMockedServiceWorker'
348
351
  },
352
+ captureSrcset: {
353
+ $ref: '/config/discovery#/properties/captureSrcset'
354
+ },
349
355
  userAgent: {
350
356
  $ref: '/config/discovery#/properties/userAgent'
351
357
  },
package/dist/discovery.js CHANGED
@@ -44,6 +44,7 @@ function debugSnapshotOptions(snapshot) {
44
44
  debugProp(snapshot, 'discovery.authorization', JSON.stringify);
45
45
  debugProp(snapshot, 'discovery.disableCache');
46
46
  debugProp(snapshot, 'discovery.captureMockedServiceWorker');
47
+ debugProp(snapshot, 'discovery.captureSrcset');
47
48
  debugProp(snapshot, 'discovery.userAgent');
48
49
  debugProp(snapshot, 'clientInfo');
49
50
  debugProp(snapshot, 'environmentInfo');
@@ -193,6 +194,14 @@ async function* captureSnapshotResources(page, snapshot, options) {
193
194
  yield page.evaluate(snapshot.execute.afterNavigation);
194
195
  }
195
196
 
197
+ // Running before page idle since this will trigger many network calls
198
+ // so need to run as early as possible. plus it is just reading urls from dom srcset
199
+ // which will be already loaded after navigation complete
200
+ if (discovery.captureSrcset) {
201
+ await page.insertPercyDom();
202
+ yield page.eval('window.PercyDOM.loadAllSrcsetLinks()');
203
+ }
204
+
196
205
  // iterate over additional snapshots for proper DOM capturing
197
206
  for (let additionalSnapshot of [baseSnapshot, ...additionalSnapshots]) {
198
207
  let isBaseSnapshot = additionalSnapshot === baseSnapshot;
package/dist/page.js CHANGED
@@ -131,6 +131,16 @@ export class Page {
131
131
  });
132
132
  for (let script of scripts) await this.eval(script);
133
133
  }
134
+ async insertPercyDom() {
135
+ // inject @percy/dom for serialization by evaluating the file contents which adds a global
136
+ // PercyDOM object that we can later check against
137
+ /* istanbul ignore next: no instrumenting injected code */
138
+ if (await this.eval(() => !window.PercyDOM)) {
139
+ this.log.debug('Inject @percy/dom', this.meta);
140
+ let script = await fs.promises.readFile(PERCY_DOM, 'utf-8');
141
+ await this.eval(new Function(script)); /* eslint-disable-line no-new-func */
142
+ }
143
+ }
134
144
 
135
145
  // Takes a snapshot after waiting for any timeout, waiting for any selector, executing any
136
146
  // scripts, and waiting for the network idle. Returns all other provided snapshot options along
@@ -171,15 +181,7 @@ export class Page {
171
181
 
172
182
  // wait for any final network activity before capturing the dom snapshot
173
183
  await this.network.idle();
174
-
175
- // inject @percy/dom for serialization by evaluating the file contents which adds a global
176
- // PercyDOM object that we can later check against
177
- /* istanbul ignore next: no instrumenting injected code */
178
- if (await this.eval(() => !window.PercyDOM)) {
179
- this.log.debug('Inject @percy/dom', this.meta);
180
- let script = await fs.promises.readFile(PERCY_DOM, 'utf-8');
181
- await this.eval(new Function(script)); /* eslint-disable-line no-new-func */
182
- }
184
+ await this.insertPercyDom();
183
185
 
184
186
  // serialize and capture a DOM snapshot
185
187
  this.log.debug('Serialize DOM', this.meta);
package/dist/snapshot.js CHANGED
@@ -128,6 +128,7 @@ function getSnapshotOptions(options, {
128
128
  authorization: config.discovery.authorization,
129
129
  disableCache: config.discovery.disableCache,
130
130
  captureMockedServiceWorker: config.discovery.captureMockedServiceWorker,
131
+ captureSrcset: config.discovery.captureSrcset,
131
132
  userAgent: config.discovery.userAgent
132
133
  }
133
134
  }, options], (path, prev, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.28.1",
3
+ "version": "1.28.2-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -43,11 +43,11 @@
43
43
  "test:types": "tsd"
44
44
  },
45
45
  "dependencies": {
46
- "@percy/client": "1.28.1",
47
- "@percy/config": "1.28.1",
48
- "@percy/dom": "1.28.1",
49
- "@percy/logger": "1.28.1",
50
- "@percy/webdriver-utils": "1.28.1",
46
+ "@percy/client": "1.28.2-beta.0",
47
+ "@percy/config": "1.28.2-beta.0",
48
+ "@percy/dom": "1.28.2-beta.0",
49
+ "@percy/logger": "1.28.2-beta.0",
50
+ "@percy/webdriver-utils": "1.28.2-beta.0",
51
51
  "content-disposition": "^0.5.4",
52
52
  "cross-spawn": "^7.0.3",
53
53
  "extract-zip": "^2.0.1",
@@ -58,5 +58,5 @@
58
58
  "rimraf": "^3.0.2",
59
59
  "ws": "^8.0.0"
60
60
  },
61
- "gitHead": "f3b0fad3c511fe9eea44eef939195a9d0310216b"
61
+ "gitHead": "0519aa061bd36acd0852b961e24c05b9ad67274f"
62
62
  }
package/types/index.d.ts CHANGED
@@ -19,6 +19,7 @@ interface DiscoveryOptions {
19
19
  allowedHostnames?: string[];
20
20
  disableCache?: boolean;
21
21
  captureMockedServiceWorker?: boolean;
22
+ captureSrcset?: boolean;
22
23
  }
23
24
 
24
25
  interface ScopeOptions {