Panic: runtime error: invalid memory address or nil pointer dereference

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();
    }
  }
}

Please anyone help me out with this issue

Hi @adnanerlansyah403,

Welcome to the forum!

I will need all the files and a publicly accessible website to be able to try and reproduce the issue. It would also help if you could copy and paste the full error message so that I can see the full stack trace.

It’s worth noting that group doesn’t work with async functions.

Cheers,
Ankur

1 Like