Skip to content

Commit 083893d

Browse files
VIA-227 JS Add initial benchmark
1 parent daf2f60 commit 083893d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

e2e/e2e-helpers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,17 @@ export const clickLinkAndExpectPageTitle = async (page: Page, linkText: string,
44
await page.getByRole("link", { name: linkText }).click();
55
await expect(page).toHaveTitle(expectedPageTitle);
66
}
7+
8+
export const benchmark = async (page: Page, target: string) => {
9+
const pageLoadTimes = [];
10+
let start;
11+
for (let i = 0; i < 3; i++) {
12+
start = performance.now();
13+
await page.goto(target);
14+
await page.waitForLoadState('load');
15+
pageLoadTimes.push(performance.now() - start);
16+
}
17+
const sumPageLoadTimes = pageLoadTimes.reduce((sum, cur) => sum + cur, 0);
18+
console.log(sumPageLoadTimes);
19+
return sumPageLoadTimes / pageLoadTimes.length;
20+
}

e2e/e2e.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
COVID_PAGE_TITLE, FLU_PAGE_TITLE, HUB_PAGE_TITLE, MENACWY_PAGE_TITLE, PNEUMO_PAGE_TITLE, RSV_PAGE_TITLE,
55
SCHEDULE_PAGE_TITLE, SHINGLES_PAGE_TITLE, SIX_IN_ONE_PAGE_TITLE
66
} from "./constants";
7-
import { clickLinkAndExpectPageTitle } from "./e2e-helpers";
7+
import { benchmark, clickLinkAndExpectPageTitle } from "./e2e-helpers";
88
import { login } from "./User";
99

1010
test.describe.configure({ mode: 'serial' });
@@ -23,6 +23,11 @@ test.describe("E2E", () => {
2323
}
2424
});
2525

26+
test("Page Load Benchmark", async () => {
27+
const bm = await(benchmark(page, "/vaccines/rsv"))
28+
expect(bm).toBeLessThanOrEqual(2500);
29+
});
30+
2631
test("Back link navigation", async () => {
2732
await page.goto("/");
2833

0 commit comments

Comments
 (0)