-
Notifications
You must be signed in to change notification settings - Fork 15
/
03.thresholds.js
43 lines (39 loc) · 1.03 KB
/
03.thresholds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { browser } from "k6/browser";
import { check } from "k6";
const BASE_URL = __ENV.BASE_URL || "http://localhost:3333";
export const options = {
scenarios: {
ui: {
executor: "shared-iterations",
options: {
browser: {
type: "chromium",
},
},
},
},
thresholds: {
browser_web_vital_fcp: ["p(95) < 1000"],
browser_web_vital_lcp: ["p(95) < 2000"],
},
};
export default async function () {
let checkData;
const page = await browser.newPage();
try {
await page.goto(BASE_URL);
checkData = await page.locator("h1").textContent();
check(page, {
header: checkData == "Looking to break out of your pizza routine?",
});
await page.locator('//button[. = "Pizza, Please!"]').click();
await page.waitForTimeout(500);
await page.screenshot({ path: "screenshot.png" });
checkData = await page.locator("div#recommendations").textContent();
check(page, {
recommendation: checkData != "",
});
} finally {
await page.close();
}
}