Hi All,
I am not seeing Total requests in HTML report or in the default command prompt logs after running below browser performance testing code. Pleae help me with any missing criteria etc.
import { browser } from 'k6/browser';
import { sleep } from 'k6';
import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js';
export const options = {
scenarios: {
HomePageTestOnBrowser: {
executor: 'per-vu-iterations',
vus: 5, // Number of virtual users
iterations: 1, // Number of iterations per virtual user
options: {
browser: {
type: 'chromium',
headless: true,
},
},
},
}
};
// Global counter variable
let totalRequests = 0;
export default async function () {
const page = await browser.newPage();
try {
const response = await page.goto('https://google.com/', { waitUntil: 'networkidle', timeout: 60000 });
sleep(4);
console.log('Status Code:', response.status());
// Increment the counter
totalRequests += 1;
} finally {
await page.close();
}
}
// Log the total number of requests at the end of the test
export function handleSummary(data) {
console.log(`Total Requests: ${totalRequests}`);
return {
'reportPageLoad.html': htmlReport(data),
};
}