Slide 22
Slide 22 text
import http from 'k6/http';
import { browser } from 'k6/browser';
import { check, sleep } from 'k6';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
exec: 'browserTest',
iterations: 10,
startTime: "20s",
options: {
browser: {
type: 'chromium',
},
},
},
background: {
executor: 'ramping-vus',
exec: 'backgroundLoad',
stages: [
{ duration: "20s", target: 20 },
{ duration: "1m", target: 20 },
],
}
},
thresholds: {
checks: ['rate==1.0'],
browser_web_vital_ttfb: ['p(95)<50'],
browser_web_vital_fcp: ['p(95)<100'],
},
};
export async function browserTest() {
const context = await browser.newContext();
const page = await context.newPage();
try {
await page.goto("http://localhost");
Use MULTIPLE SCENARIOS to
keep up an constant average load
in the background while observing
browser metrics