feat: implement Core Web Vitals monitoring in MobilePerformanceMonitor

This commit is contained in:
张翔
2026-03-05 15:23:16 +08:00
parent 3f18618c84
commit 834dbcadf4
2 changed files with 44 additions and 5 deletions
@@ -13,13 +13,14 @@ test.describe('MobilePerformanceMonitor', () => {
expect(vitals.CLS).toBeGreaterThanOrEqual(0);
});
test('should run Lighthouse audit', async ({ page }) => {
await page.goto('/');
test('should get Core Web Vitals on product page', async ({ page }) => {
await page.goto('/products');
const monitor = new MobilePerformanceMonitor(page);
const result = await monitor.runLighthouseAudit(page.url());
const vitals = await monitor.getCoreWebVitals();
expect(result.score).toBeGreaterThan(0);
expect(result.audits).toBeDefined();
expect(vitals.FCP).toBeGreaterThan(0);
expect(vitals.LCP).toBeGreaterThan(0);
expect(vitals.CLS).toBeGreaterThanOrEqual(0);
});
});