@percy/core 1.29.3 → 1.29.4-beta.2
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 +14 -0
- package/dist/discovery.js +14 -1
- package/dist/network.js +2 -1
- package/dist/snapshot.js +2 -0
- package/dist/utils.js +9 -0
- package/package.json +8 -8
package/dist/config.js
CHANGED
|
@@ -205,6 +205,14 @@ export const configSchema = {
|
|
|
205
205
|
maximum: 750,
|
|
206
206
|
minimum: 1
|
|
207
207
|
},
|
|
208
|
+
waitForSelector: {
|
|
209
|
+
type: 'string'
|
|
210
|
+
},
|
|
211
|
+
waitForTimeout: {
|
|
212
|
+
type: 'integer',
|
|
213
|
+
minimum: 1,
|
|
214
|
+
maximum: 30000
|
|
215
|
+
},
|
|
208
216
|
disableCache: {
|
|
209
217
|
type: 'boolean'
|
|
210
218
|
},
|
|
@@ -363,6 +371,12 @@ export const snapshotSchema = {
|
|
|
363
371
|
requestHeaders: {
|
|
364
372
|
$ref: '/config/discovery#/properties/requestHeaders'
|
|
365
373
|
},
|
|
374
|
+
waitForSelector: {
|
|
375
|
+
$ref: '/config/discovery#/properties/waitForSelector'
|
|
376
|
+
},
|
|
377
|
+
waitForTimeout: {
|
|
378
|
+
$ref: '/config/discovery#/properties/waitForTimeout'
|
|
379
|
+
},
|
|
366
380
|
authorization: {
|
|
367
381
|
$ref: '/config/discovery#/properties/authorization'
|
|
368
382
|
},
|
package/dist/discovery.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logger from '@percy/logger';
|
|
2
2
|
import Queue from './queue.js';
|
|
3
|
-
import
|
|
3
|
+
import Page from './page.js';
|
|
4
|
+
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName, waitForTimeout, withRetries, waitForSelectorInsideBrowser } from './utils.js';
|
|
4
5
|
import { sha256hash } from '@percy/client/utils';
|
|
5
6
|
import Pako from 'pako';
|
|
6
7
|
import TimeIt from './timing.js';
|
|
@@ -238,6 +239,18 @@ async function* captureSnapshotResources(page, snapshot, options) {
|
|
|
238
239
|
yield page.goto(snapshot.url, {
|
|
239
240
|
cookies
|
|
240
241
|
});
|
|
242
|
+
|
|
243
|
+
// wait for any specified timeout
|
|
244
|
+
if (snapshot.discovery.waitForTimeout && page.enableJavaScript) {
|
|
245
|
+
log.debug(`Wait for ${snapshot.discovery.waitForTimeout}ms timeout`);
|
|
246
|
+
await waitForTimeout(snapshot.discovery.waitForTimeout);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// wait for any specified selector
|
|
250
|
+
if (snapshot.discovery.waitForSelector && page.enableJavaScript) {
|
|
251
|
+
log.debug(`Wait for selector: ${snapshot.discovery.waitForSelector}`);
|
|
252
|
+
await waitForSelectorInsideBrowser(page, snapshot.discovery.waitForSelector, Page.TIMEOUT);
|
|
253
|
+
}
|
|
241
254
|
if (snapshot.execute) {
|
|
242
255
|
// when any execute options are provided, inject snapshot options
|
|
243
256
|
/* istanbul ignore next: cannot detect coverage of injected code */
|
package/dist/network.js
CHANGED
|
@@ -472,7 +472,8 @@ async function saveResponseResource(network, request) {
|
|
|
472
472
|
let response = request.response;
|
|
473
473
|
let meta = {
|
|
474
474
|
...network.meta,
|
|
475
|
-
url
|
|
475
|
+
url,
|
|
476
|
+
responseStatus: response === null || response === void 0 ? void 0 : response.status
|
|
476
477
|
};
|
|
477
478
|
let resource = network.intercept.getResource(url);
|
|
478
479
|
if (!resource || !resource.root && !resource.provided && disableCache) {
|
package/dist/snapshot.js
CHANGED
|
@@ -142,6 +142,8 @@ function getSnapshotOptions(options, {
|
|
|
142
142
|
allowedHostnames: config.discovery.allowedHostnames,
|
|
143
143
|
disallowedHostnames: config.discovery.disallowedHostnames,
|
|
144
144
|
networkIdleTimeout: config.discovery.networkIdleTimeout,
|
|
145
|
+
waitForTimeout: config.discovery.waitForTimeout,
|
|
146
|
+
waitForSelector: config.discovery.waitForSelector,
|
|
145
147
|
devicePixelRatio: config.discovery.devicePixelRatio,
|
|
146
148
|
requestHeaders: config.discovery.requestHeaders,
|
|
147
149
|
authorization: config.discovery.authorization,
|
package/dist/utils.js
CHANGED
|
@@ -274,6 +274,15 @@ async function waitForSelector(selector, timeout) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
// wait for a query selector to exist within an optional timeout inside browser
|
|
278
|
+
export async function waitForSelectorInsideBrowser(page, selector, timeout) {
|
|
279
|
+
try {
|
|
280
|
+
return page.eval(`await waitForSelector(${JSON.stringify(selector)}, ${timeout})`);
|
|
281
|
+
} catch {
|
|
282
|
+
throw new Error(`Unable to find: ${selector}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
277
286
|
// Browser-specific util to wait for an xpath selector to exist within an optional timeout.
|
|
278
287
|
/* istanbul ignore next: tested, but coverage is stripped */
|
|
279
288
|
async function waitForXPath(selector, timeout) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.4-beta.2",
|
|
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": "
|
|
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.29.
|
|
47
|
-
"@percy/config": "1.29.
|
|
48
|
-
"@percy/dom": "1.29.
|
|
49
|
-
"@percy/logger": "1.29.
|
|
50
|
-
"@percy/webdriver-utils": "1.29.
|
|
46
|
+
"@percy/client": "1.29.4-beta.2",
|
|
47
|
+
"@percy/config": "1.29.4-beta.2",
|
|
48
|
+
"@percy/dom": "1.29.4-beta.2",
|
|
49
|
+
"@percy/logger": "1.29.4-beta.2",
|
|
50
|
+
"@percy/webdriver-utils": "1.29.4-beta.2",
|
|
51
51
|
"content-disposition": "^0.5.4",
|
|
52
52
|
"cross-spawn": "^7.0.3",
|
|
53
53
|
"extract-zip": "^2.0.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"ws": "^8.17.1",
|
|
61
61
|
"yaml": "^2.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f316b7f672fbec81d3f13c53591735f102bc17a1"
|
|
64
64
|
}
|