@wordpress/e2e-test-utils-playwright 0.9.1-next.5a1d1283.0 → 0.10.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/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/lighthouse/index.js +60 -0
- package/build/lighthouse/index.js.map +1 -0
- package/build/metrics/index.js +84 -0
- package/build/metrics/index.js.map +1 -0
- package/build/test.js +23 -0
- package/build/test.js.map +1 -1
- package/build-types/index.d.ts +2 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lighthouse/index.d.ts +17 -0
- package/build-types/lighthouse/index.d.ts.map +1 -0
- package/build-types/metrics/index.d.ts +41 -0
- package/build-types/metrics/index.d.ts.map +1 -0
- package/build-types/test.d.ts +4 -1
- package/build-types/test.d.ts.map +1 -1
- package/build-types/types.d.ts +16 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +7 -5
package/build/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.expect = exports.test = exports.RequestUtils = exports.PageUtils = exports.Editor = exports.Admin = void 0;
|
|
17
|
+
exports.expect = exports.test = exports.Lighthouse = exports.Metrics = exports.RequestUtils = exports.PageUtils = exports.Editor = exports.Admin = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
var admin_1 = require("./admin");
|
|
20
20
|
Object.defineProperty(exports, "Admin", { enumerable: true, get: function () { return admin_1.Admin; } });
|
|
@@ -24,6 +24,10 @@ var page_utils_1 = require("./page-utils");
|
|
|
24
24
|
Object.defineProperty(exports, "PageUtils", { enumerable: true, get: function () { return page_utils_1.PageUtils; } });
|
|
25
25
|
var request_utils_1 = require("./request-utils");
|
|
26
26
|
Object.defineProperty(exports, "RequestUtils", { enumerable: true, get: function () { return request_utils_1.RequestUtils; } });
|
|
27
|
+
var metrics_1 = require("./metrics");
|
|
28
|
+
Object.defineProperty(exports, "Metrics", { enumerable: true, get: function () { return metrics_1.Metrics; } });
|
|
29
|
+
var lighthouse_1 = require("./lighthouse");
|
|
30
|
+
Object.defineProperty(exports, "Lighthouse", { enumerable: true, get: function () { return lighthouse_1.Lighthouse; } });
|
|
27
31
|
var test_1 = require("./test");
|
|
28
32
|
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_1.test; } });
|
|
29
33
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,+BAAsC;AAA7B,4FAAA,IAAI,OAAA;AAAE,8FAAA,MAAM,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+BAAsC;AAA7B,4FAAA,IAAI,OAAA;AAAE,8FAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lighthouse = void 0;
|
|
4
|
+
const lighthouse = require("lighthouse/core/index.cjs");
|
|
5
|
+
class Lighthouse {
|
|
6
|
+
page;
|
|
7
|
+
port;
|
|
8
|
+
constructor(page, port) {
|
|
9
|
+
this.page = page;
|
|
10
|
+
this.port = port;
|
|
11
|
+
this.page = page;
|
|
12
|
+
this.port = port;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the Lighthouse report for the current URL.
|
|
16
|
+
*
|
|
17
|
+
* Runs several Lighthouse audits in a separate browser window and returns
|
|
18
|
+
* the summary.
|
|
19
|
+
*/
|
|
20
|
+
async getReport() {
|
|
21
|
+
// From https://github.com/GoogleChrome/lighthouse/blob/d149e9c1b628d5881ca9ca451278d99ff1b31d9a/core/config/default-config.js#L433-L503
|
|
22
|
+
const audits = {
|
|
23
|
+
'largest-contentful-paint': 'LCP',
|
|
24
|
+
'total-blocking-time': 'TBT',
|
|
25
|
+
interactive: 'TTI',
|
|
26
|
+
'cumulative-layout-shift': 'CLS',
|
|
27
|
+
'experimental-interaction-to-next-paint': 'INP',
|
|
28
|
+
};
|
|
29
|
+
const report = await lighthouse(this.page.url(), { port: this.port }, {
|
|
30
|
+
extends: 'lighthouse:default',
|
|
31
|
+
settings: {
|
|
32
|
+
// "provided" means no throttling.
|
|
33
|
+
// TODO: Make configurable.
|
|
34
|
+
throttlingMethod: 'provided',
|
|
35
|
+
// Default is "mobile".
|
|
36
|
+
// See https://github.com/GoogleChrome/lighthouse/blob/main/docs/emulation.md
|
|
37
|
+
// TODO: Make configurable.
|
|
38
|
+
formFactor: 'desktop',
|
|
39
|
+
screenEmulation: {
|
|
40
|
+
disabled: true,
|
|
41
|
+
},
|
|
42
|
+
// Speeds up the report.
|
|
43
|
+
disableFullPageScreenshot: true,
|
|
44
|
+
// Only run certain audits to speed things up.
|
|
45
|
+
onlyAudits: Object.keys(audits),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const result = {};
|
|
49
|
+
if (!report) {
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
const { lhr } = report;
|
|
53
|
+
for (const [audit, acronym] of Object.entries(audits)) {
|
|
54
|
+
result[acronym] = lhr.audits[audit]?.numericValue || 0;
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Lighthouse = Lighthouse;
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lighthouse/index.ts"],"names":[],"mappings":";;;AAIA,wDAAwD;AAExD,MAAa,UAAU;IAEL;IACA;IAFjB,YACiB,IAAU,EACV,IAAY;QADZ,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAQ;QAE5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACd,wIAAwI;QACxI,MAAM,MAAM,GAAG;YACd,0BAA0B,EAAE,KAAK;YACjC,qBAAqB,EAAE,KAAK;YAC5B,WAAW,EAAE,KAAK;YAClB,yBAAyB,EAAE,KAAK;YAChC,wCAAwC,EAAE,KAAK;SAC/C,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EACf,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EACnB;YACC,OAAO,EAAE,oBAAoB;YAC7B,QAAQ,EAAE;gBACT,kCAAkC;gBAClC,2BAA2B;gBAC3B,gBAAgB,EAAE,UAAU;gBAC5B,uBAAuB;gBACvB,6EAA6E;gBAC7E,2BAA2B;gBAC3B,UAAU,EAAE,SAAS;gBACrB,eAAe,EAAE;oBAChB,QAAQ,EAAE,IAAI;iBACd;gBACD,wBAAwB;gBACxB,yBAAyB,EAAE,IAAI;gBAC/B,8CAA8C;gBAC9C,UAAU,EAAE,MAAM,CAAC,IAAI,CAAE,MAAM,CAAE;aACjC;SACD,CACD,CAAC;QAEF,MAAM,MAAM,GAA6B,EAAE,CAAC;QAE5C,IAAK,CAAE,MAAM,EAAG;YACf,OAAO,MAAM,CAAC;SACd;QAED,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;QAEvB,KAAM,MAAM,CAAE,KAAK,EAAE,OAAO,CAAE,IAAI,MAAM,CAAC,OAAO,CAAE,MAAM,CAAE,EAAG;YAC5D,MAAM,CAAE,OAAO,CAAE,GAAG,GAAG,CAAC,MAAM,CAAE,KAAK,CAAE,EAAE,YAAY,IAAI,CAAC,CAAC;SAC3D;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA/DD,gCA+DC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Metrics = void 0;
|
|
4
|
+
class Metrics {
|
|
5
|
+
page;
|
|
6
|
+
constructor(page) {
|
|
7
|
+
this.page = page;
|
|
8
|
+
this.page = page;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns durations from the Server-Timing header.
|
|
12
|
+
*
|
|
13
|
+
* @param fields Optional fields to filter.
|
|
14
|
+
*/
|
|
15
|
+
async getServerTiming(fields = []) {
|
|
16
|
+
return this.page.evaluate((f) => performance.getEntriesByType('navigation')[0].serverTiming.reduce((acc, entry) => {
|
|
17
|
+
if (f.length === 0 || f.includes(entry.name)) {
|
|
18
|
+
acc[entry.name] = entry.duration;
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, {}), fields);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns time to first byte (TTFB) using the Navigation Timing API.
|
|
25
|
+
*
|
|
26
|
+
* @see https://web.dev/ttfb/#measure-ttfb-in-javascript
|
|
27
|
+
*
|
|
28
|
+
* @return {Promise<number>} TTFB value.
|
|
29
|
+
*/
|
|
30
|
+
async getTimeToFirstByte() {
|
|
31
|
+
return this.page.evaluate(() => {
|
|
32
|
+
const { responseStart, startTime } = performance.getEntriesByType('navigation')[0];
|
|
33
|
+
return responseStart - startTime;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the Largest Contentful Paint (LCP) value using the dedicated API.
|
|
38
|
+
*
|
|
39
|
+
* @see https://w3c.github.io/largest-contentful-paint/
|
|
40
|
+
* @see https://web.dev/lcp/#measure-lcp-in-javascript
|
|
41
|
+
*
|
|
42
|
+
* @return {Promise<number>} LCP value.
|
|
43
|
+
*/
|
|
44
|
+
async getLargestContentfulPaint() {
|
|
45
|
+
return this.page.evaluate(() => new Promise((resolve) => {
|
|
46
|
+
new PerformanceObserver((entryList) => {
|
|
47
|
+
const entries = entryList.getEntries();
|
|
48
|
+
// The last entry is the largest contentful paint.
|
|
49
|
+
const largestPaintEntry = entries.at(-1);
|
|
50
|
+
resolve(largestPaintEntry?.startTime || 0);
|
|
51
|
+
}).observe({
|
|
52
|
+
type: 'largest-contentful-paint',
|
|
53
|
+
buffered: true,
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the Cumulative Layout Shift (CLS) value using the dedicated API.
|
|
59
|
+
*
|
|
60
|
+
* @see https://github.com/WICG/layout-instability
|
|
61
|
+
* @see https://web.dev/cls/#measure-layout-shifts-in-javascript
|
|
62
|
+
*
|
|
63
|
+
* @return {Promise<number>} CLS value.
|
|
64
|
+
*/
|
|
65
|
+
async getCumulativeLayoutShift() {
|
|
66
|
+
return this.page.evaluate(() => new Promise((resolve) => {
|
|
67
|
+
let CLS = 0;
|
|
68
|
+
new PerformanceObserver((l) => {
|
|
69
|
+
const entries = l.getEntries();
|
|
70
|
+
entries.forEach((entry) => {
|
|
71
|
+
if (!entry.hadRecentInput) {
|
|
72
|
+
CLS += entry.value;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
resolve(CLS);
|
|
76
|
+
}).observe({
|
|
77
|
+
type: 'layout-shift',
|
|
78
|
+
buffered: true,
|
|
79
|
+
});
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.Metrics = Metrics;
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":";;;AAKA,MAAa,OAAO;IACU;IAA7B,YAA6B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAE,SAAmB,EAAE;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CACxB,CAAE,CAAW,EAAG,EAAE,CAEhB,WAAW,CAAC,gBAAgB,CAC3B,YAAY,CAEZ,CAAE,CAAC,CAAE,CAAC,YAAY,CAAC,MAAM,CAC1B,CAAE,GAAG,EAAE,KAAK,EAAG,EAAE;YAChB,IAAK,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAE,KAAK,CAAC,IAAI,CAAE,EAAG;gBACjD,GAAG,CAAE,KAAK,CAAC,IAAI,CAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;aACnC;YACD,OAAO,GAAG,CAAC;QACZ,CAAC,EACD,EAA8B,CAC9B,EACF,MAAM,CACN,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,kBAAkB;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAY,GAAG,EAAE;YACzC,MAAM,EAAE,aAAa,EAAE,SAAS,EA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AAC,CAAE,CAAC,OAAO,CAAE;gBACZ,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,IAAI;aACd,CAAE,CAAC;QACL,CAAC,CAAE,CACJ,CAAC;IACH,CAAC;CACD;AAzGD,0BAyGC"}
|
package/build/test.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.expect = exports.test = void 0;
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const test_1 = require("@playwright/test");
|
|
9
9
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
|
|
10
|
+
const getPort = require("get-port");
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
12
13
|
*/
|
|
@@ -115,6 +116,28 @@ const test = test_1.test.extend({
|
|
|
115
116
|
},
|
|
116
117
|
{ scope: 'worker', auto: true },
|
|
117
118
|
],
|
|
119
|
+
// Spins up a new browser for use by the Lighthouse fixture
|
|
120
|
+
// so that Lighthouse can connect to the debugging port.
|
|
121
|
+
// As a worker-scoped fixture, this will only launch 1
|
|
122
|
+
// instance for the whole test worker, so multiple tests
|
|
123
|
+
// will share the same instance with the same port.
|
|
124
|
+
lighthousePort: [
|
|
125
|
+
async ({}, use) => {
|
|
126
|
+
const port = await getPort();
|
|
127
|
+
const browser = await test_1.chromium.launch({
|
|
128
|
+
args: [`--remote-debugging-port=${port}`],
|
|
129
|
+
});
|
|
130
|
+
await use(port);
|
|
131
|
+
await browser.close();
|
|
132
|
+
},
|
|
133
|
+
{ scope: 'worker' },
|
|
134
|
+
],
|
|
135
|
+
lighthouse: async ({ page, lighthousePort }, use) => {
|
|
136
|
+
await use(new index_1.Lighthouse(page, lighthousePort));
|
|
137
|
+
},
|
|
138
|
+
metrics: async ({ page }, use) => {
|
|
139
|
+
await use(new index_1.Metrics(page));
|
|
140
|
+
},
|
|
118
141
|
});
|
|
119
142
|
exports.test = test;
|
|
120
143
|
//# sourceMappingURL=test.js.map
|
package/build/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,6BAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,6BAA6B;AAC7B,2CAAkE;AAqLnD,uFArLQ,aAAM,OAqLR;AAnLrB,oCAAoC;AAEpC;;GAEG;AACH,mCAOiB;AAEjB,MAAM,kBAAkB,GACvB,OAAO,CAAC,GAAG,CAAC,kBAAkB;IAC9B,IAAI,CAAC,IAAI,CAAE,OAAO,CAAC,GAAG,EAAE,EAAE,qCAAqC,CAAE,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,CAAE,MAAM,EAAE,OAAO,CAAW,CAAC;AAEpE;;;;;GAKG;AACH,SAAS,qBAAqB,CAAE,OAAuB;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,IACC,CAAE,8BAA8B,CAAC,QAAQ,CACxC,IAA2D,CAC3D,EACA;QACD,OAAO;KACP;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAE5B,iEAAiE;IACjE,kEAAkE;IAClE,IAAK,IAAI,CAAC,QAAQ,CAAE,0BAA0B,CAAE,EAAG;QAClD,OAAO;KACP;IAED,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,oDAAoD;IACpD,6DAA6D;IAC7D,6DAA6D;IAC7D,IAAK,IAAI,CAAC,QAAQ,CAAE,gDAAgD,CAAE,EAAG;QACxE,OAAO;KACP;IAED,iEAAiE;IACjE,oCAAoC;IACpC,IAAK,IAAI,CAAC,QAAQ,CAAE,6BAA6B,CAAE,EAAG;QACrD,OAAO;KACP;IAED,6BAA6B;IAC7B,kEAAkE;IAClE,gBAAgB;IAChB,OAAO;IACP,wDAAwD;IACxD,mBAAmB;IACnB,MAAM;IACN,WAAW;IACX,IAAI;IA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AG,EAAE;QAClC,MAAM,GAAG,CAAE,IAAI,eAAO,CAAE,IAAI,CAAE,CAAE,CAAC;IAClC,CAAC;CACD,CAAE,CAAC;AAEK,oBAAI"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export { Admin } from './admin';
|
|
|
3
3
|
export { Editor } from './editor';
|
|
4
4
|
export { PageUtils } from './page-utils';
|
|
5
5
|
export { RequestUtils } from './request-utils';
|
|
6
|
+
export { Metrics } from './metrics';
|
|
7
|
+
export { Lighthouse } from './lighthouse';
|
|
6
8
|
export { test, expect } from './test';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Page } from '@playwright/test';
|
|
5
|
+
export declare class Lighthouse {
|
|
6
|
+
readonly page: Page;
|
|
7
|
+
readonly port: number;
|
|
8
|
+
constructor(page: Page, port: number);
|
|
9
|
+
/**
|
|
10
|
+
* Returns the Lighthouse report for the current URL.
|
|
11
|
+
*
|
|
12
|
+
* Runs several Lighthouse audits in a separate browser window and returns
|
|
13
|
+
* the summary.
|
|
14
|
+
*/
|
|
15
|
+
getReport(): Promise<Record<string, number>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lighthouse/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,qBAAa,UAAU;aAEL,IAAI,EAAE,IAAI;aACV,IAAI,EAAE,MAAM;gBADZ,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM;IAM7B;;;;;OAKG;IACG,SAAS;CAgDf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Page } from '@playwright/test';
|
|
5
|
+
export declare class Metrics {
|
|
6
|
+
readonly page: Page;
|
|
7
|
+
constructor(page: Page);
|
|
8
|
+
/**
|
|
9
|
+
* Returns durations from the Server-Timing header.
|
|
10
|
+
*
|
|
11
|
+
* @param fields Optional fields to filter.
|
|
12
|
+
*/
|
|
13
|
+
getServerTiming(fields?: string[]): Promise<Record<string, number>>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns time to first byte (TTFB) using the Navigation Timing API.
|
|
16
|
+
*
|
|
17
|
+
* @see https://web.dev/ttfb/#measure-ttfb-in-javascript
|
|
18
|
+
*
|
|
19
|
+
* @return {Promise<number>} TTFB value.
|
|
20
|
+
*/
|
|
21
|
+
getTimeToFirstByte(): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the Largest Contentful Paint (LCP) value using the dedicated API.
|
|
24
|
+
*
|
|
25
|
+
* @see https://w3c.github.io/largest-contentful-paint/
|
|
26
|
+
* @see https://web.dev/lcp/#measure-lcp-in-javascript
|
|
27
|
+
*
|
|
28
|
+
* @return {Promise<number>} LCP value.
|
|
29
|
+
*/
|
|
30
|
+
getLargestContentfulPaint(): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the Cumulative Layout Shift (CLS) value using the dedicated API.
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/WICG/layout-instability
|
|
35
|
+
* @see https://web.dev/cls/#measure-layout-shifts-in-javascript
|
|
36
|
+
*
|
|
37
|
+
* @return {Promise<number>} CLS value.
|
|
38
|
+
*/
|
|
39
|
+
getCumulativeLayoutShift(): Promise<number>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,OAAO;aACU,IAAI,EAAE,IAAI;gBAAV,IAAI,EAAE,IAAI;IAIvC;;;;OAIG;IACG,eAAe,CAAE,MAAM,GAAE,MAAM,EAAO;IAoB5C;;;;;;OAMG;IACG,kBAAkB;IAWxB;;;;;;;OAOG;IACG,yBAAyB;IAkB/B;;;;;;;OAOG;IACG,wBAAwB;CAuB9B"}
|
package/build-types/test.d.ts
CHANGED
|
@@ -2,14 +2,17 @@ import { expect } from '@playwright/test';
|
|
|
2
2
|
/**
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { Admin, Editor, PageUtils, RequestUtils } from './index';
|
|
5
|
+
import { Admin, Editor, PageUtils, RequestUtils, Metrics, Lighthouse } from './index';
|
|
6
6
|
declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
7
7
|
admin: Admin;
|
|
8
8
|
editor: Editor;
|
|
9
9
|
pageUtils: PageUtils;
|
|
10
10
|
snapshotConfig: void;
|
|
11
|
+
metrics: Metrics;
|
|
12
|
+
lighthouse: Lighthouse;
|
|
11
13
|
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
|
|
12
14
|
requestUtils: RequestUtils;
|
|
15
|
+
lighthousePort: number;
|
|
13
16
|
}>;
|
|
14
17
|
export { test, expect };
|
|
15
18
|
//# sourceMappingURL=test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAIlE;;GAEG;AACH,OAAO,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,YAAY,EACZ,OAAO,EACP,UAAU,EACV,MAAM,SAAS,CAAC;AAyFjB,QAAA,MAAM,IAAI;WAED,KAAK;YACJ,MAAM;eACH,SAAS;oBACJ,IAAI;aACX,OAAO;gBACJ,UAAU;;kBAGR,YAAY;oBACV,MAAM;EAiErB,CAAC;AAEJ,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -2,6 +2,22 @@ declare global {
|
|
|
2
2
|
interface Window {
|
|
3
3
|
wp: any;
|
|
4
4
|
}
|
|
5
|
+
interface LayoutShiftAttribution {
|
|
6
|
+
readonly node: Node;
|
|
7
|
+
readonly previousRect: DOMRectReadOnly;
|
|
8
|
+
readonly currentRect: DOMRectReadOnly;
|
|
9
|
+
readonly toJSON: () => string;
|
|
10
|
+
}
|
|
11
|
+
interface LayoutShift extends PerformanceEntry {
|
|
12
|
+
readonly duration: number;
|
|
13
|
+
readonly entryType: 'layout-shift';
|
|
14
|
+
readonly name: 'layout-shift';
|
|
15
|
+
readonly startTime: DOMHighResTimeStamp;
|
|
16
|
+
readonly value: number;
|
|
17
|
+
readonly hadRecentInput: boolean;
|
|
18
|
+
readonly lastInputTime: DOMHighResTimeStamp;
|
|
19
|
+
readonly sources: LayoutShiftAttribution[];
|
|
20
|
+
}
|
|
5
21
|
}
|
|
6
22
|
export {};
|
|
7
23
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QAEf,EAAE,EAAE,GAAG,CAAC;KACR;CACD;AAED,OAAO,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QAEf,EAAE,EAAE,GAAG,CAAC;KACR;IAID,UAAU,sBAAsB;QAC/B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QACpB,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;QACvC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;QACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC;KAC9B;IAID,UAAU,WAAY,SAAQ,gBAAgB;QAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;QACnC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QAC9B,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;QACjC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;QAC5C,QAAQ,CAAC,OAAO,EAAE,sBAAsB,EAAE,CAAC;KAC3C;CACD;AAED,OAAO,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/e2e-test-utils-playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "End-To-End (E2E) test utils for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,11 +30,13 @@
|
|
|
30
30
|
"main": "./build/index.js",
|
|
31
31
|
"types": "./build-types",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@wordpress/api-fetch": "^6.
|
|
34
|
-
"@wordpress/keycodes": "^3.
|
|
35
|
-
"@wordpress/url": "^3.
|
|
33
|
+
"@wordpress/api-fetch": "^6.39.0",
|
|
34
|
+
"@wordpress/keycodes": "^3.42.0",
|
|
35
|
+
"@wordpress/url": "^3.43.0",
|
|
36
36
|
"change-case": "^4.1.2",
|
|
37
37
|
"form-data": "^4.0.0",
|
|
38
|
+
"get-port": "^5.1.1",
|
|
39
|
+
"lighthouse": "^10.4.0",
|
|
38
40
|
"mime": "^3.0.0"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
@@ -43,5 +45,5 @@
|
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "cc35f517ed017ab7131319af3e87c359e8de175d"
|
|
47
49
|
}
|