Hello everyone, can anyone help me out about how to fix this error? So wheneverI tried to run the performance test for web I always got error like that even though my data has already been there.
- File mainPage.js
import { group, sleep } from "k6";
import { Rate } from "k6/metrics";
import { config, k6config } from "./k6.config.js";
import { accountUser, baseURL, serviceURL, slug } from "./helpers/common.js";
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
import { Homepage } from "./pageObjectModel/Homepage.js";
export const pageOptions = config
// export let errorRate = new Rate('Failed Requests');
/**
* Pages
*/
var homepage = new Homepage(baseURL);
export function setup() {
console.log('>>>>>>>> Starting ⌛ <<<<<<<<<')
}
export default function () {
// Pages
group('Visit Homepage', () => {
// homepage.testHomePage();
})
// errorRate.add(!auth.getResult())
sleep(1)
}
export function teardown(data) {
console.log('>>>>>>>> TESTING COMPLETED <<<<<<<<<')
}
export function handleSummary(data) {
console.log('>>>>>>>> GENERATING REPORT <<<<<<<<<')
let date = new Date();
return {
[`report-${__ENV.NODE_ENV}-${slug}-${date.getFullYear()}-${date.getMonth()}-${date.getDate()}` + "_summary.html"]: htmlReport(data),
stdout: textSummary(data, { indent: " ", enableColors: true }),
};
}
- File Homepage.js
import { browser } from 'k6/experimental/browser';
import { sleep } from 'k6';
import { baseURL } from '../helpers/common.js';
import { config } from '../k6.config.js';
import { BasePage } from '../helpers/basePage.js';
export class Homepage extends BasePage {
constructor(endpoint) {
super(endpoint);
// this.url = this.url.concat('auth/');
}
async testHomePage() {
const page = browser.newPage();
try {
// Test logic for the home page
await page.goto(baseURL);
sleep(1);
} finally {
await page.close();
}
}
}