-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(playwright performance): Pw perf tests (#959)
* feat: initial perf tests for routes fix: refactor * Fix: updated per review comments --------- Co-authored-by: asharonbaltazar <[email protected]>
- Loading branch information
1 parent
f0b89cc
commit b92334d
Showing
3 changed files
with
99 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
export const STATIC = [ | ||
"/", | ||
"/dashboard", | ||
"/faq", | ||
"/profile", | ||
"/new-submission", | ||
"/new-submission/spa", | ||
"/new-submission/spa/medicaid", | ||
"/new-submission/spa/chip", | ||
"/new-submission/waiver", | ||
"/new-submission/waiver/b", | ||
"/new-submission/waiver/b/b4", | ||
"/new-submission/waiver/b/capitated", | ||
"/new-submission/spa/medicaid/landing/medicaid-eligibility", | ||
"/new-submission/waiver/b/capitated/amendment/create", | ||
"/new-submission/waiver/b/capitated/renewal/create", | ||
"/new-submission/waiver/b/capitated/initial/create", | ||
"/new-submission/waiver/b/b4/initial/create", | ||
"/new-submission/waiver/b/b4/amendment/create", | ||
"/new-submission/waiver/b/b4/renewal/create", | ||
"/new-submission/spa/medicaid/create", | ||
"/new-submission/spa/chip/create", | ||
"/new-submission/waiver/app-k", | ||
"/new-submission/waiver/temporary-extensions", | ||
]; | ||
|
||
export const WEBFORM = [ | ||
"/guides/abp", | ||
"/webform/g3/202401", | ||
"/webform/g2b/202401", | ||
"/webform/g2a/202401", | ||
"/webform/g1/202401", | ||
"/webform/cs8/202401", | ||
"/webform/cs3/202401", | ||
"/webform/cs7/202401", | ||
"/webform/abp11/202401", | ||
"/webform/abp10/202401", | ||
"/webform/abp9/202401", | ||
"/webform/abp7/202401", | ||
"/webform/abp6/202401", | ||
"/webform/abp5/202401", | ||
"/webform/abp4/202401", | ||
"/webform/abp3_1/202401", | ||
"/webform/abp3/202401", | ||
"/webform/abp2c/202401", | ||
"/webform/abp2b/202401", | ||
"/webform/abp2a/202401", | ||
"/webform/abp1/202401", | ||
"/webform/abp1/202402", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { test } from "@playwright/test"; | ||
import * as routes from "../fixtures/routes"; | ||
|
||
const STATIC_ROUTES = routes.STATIC; | ||
|
||
test.describe("test performance on static routes", { tag: ["@perf"] }, () => { | ||
for (const route of STATIC_ROUTES) { | ||
test(`Time to First Byte for ${route}`, { tag: ["@ttfb"] }, async({ page }) => { | ||
await page.goto(route); | ||
const ttfb = await page.evaluate(() => performance.timing.responseStart - performance.timing.requestStart) | ||
console.log(`TTFB for ${route}: ${ttfb} ms`); | ||
}); | ||
|
||
test(`Largest Contentful Paint for ${route}`, { tag: ["@lcp"] }, async ({ page }) => { | ||
await page.goto(route); | ||
const lcp = await page.evaluate(async () => { | ||
return new Promise((resolve) => { | ||
new PerformanceObserver((entryList) => { | ||
const entries = entryList.getEntries(); | ||
resolve(entries[entries.length - 1]); | ||
}).observe({ type: 'largest-contentful-paint', buffered: true }); | ||
}); | ||
}); | ||
|
||
console.log(`Largest Contentful Paint for ${route} is: ${lcp.startTime} ms`); | ||
}); | ||
|
||
test(`First Contentful Paint for ${route}`, { tag: ["@fcp"] }, async ({ page }) => { | ||
await page.goto(route); | ||
const fcp = await page.evaluate(async () => { | ||
return new Promise((resolve) => { | ||
new PerformanceObserver((entryList) => { | ||
const entries = entryList.getEntries(); | ||
resolve(entries[0]); | ||
}).observe({ type: 'paint', buffered: true }); | ||
}); | ||
}); | ||
|
||
console.log(`First Contentful Paint for ${route} is: ${fcp.startTime} ms`); | ||
}); | ||
} | ||
}); |