Facing Issue in using scenarios feature for multiple files

I have a scenario where I am trying to utilize a function defined in different js file(separate module)
I tried to implement below config in main file.

Solution tried:

Main File:

import { getAPI } from “./ComponentPerf_GET.js”;

export const options = {
scenarios: {
scenario1: {
executor: “constant-vus”,
exec: “getAPI”,
vus: 1,
duration: “15s”,

},  },

export default function(){
getAPI();
}

ComponentGET.js:

export function getAPI() {
group(“GET_API”, function () {
response = http.get(getUrl, requestheaders);
}};

Error:
There were problems with the specified script configuration:\n\t- executor scenario1: function ‘getAPI’ not found in exports"

Tried to implement the solution mentioned in below thread but no luck

Hi @Komal,

You are giving getAPI as the function that k6 needs to execute as the default function for scenario scenario1 - this is waht exec: "getAPI" means. But your main files imports getAPI and never exports it, instead you call it in the default function, which won’t be used as you have defined that k6 should call getAPI.

You can fix this in two ways:

  1. don’t specify exec and k6 will call default which in itself calls getAPI
  2. (re)export getAPI with export {getAPI} from "./Compo...."

Hope this explanation is understandable as unfortunately it uses default a bit too much :grimacing: .

p.s. you are importing ComponenetPerf_GET.js but have named it (here) ComponentGET.js, hopefully this is a copy-paste error :wink:

Hey @mstoykov
Thanks for your quick help :slight_smile:
1st option would not help me because I have to use multiple modules.
2nd option helped me resolved the issue.
After defining the export function as below I am able to execute the test.

Solution Implemented:

Main file (added below changes, removing the default function)
export const options = {
scenarios: {
scenario1: {
executor: “constant-vus”,
exec: “get”,
vus: 1,
duration: “15s”,

}, },

export function get() {

getAPI();

}