Greetings,
I am facing an issue accessing an exported function when invoked from a executor/scenario.
Here are a few details:
File: helper-functions.js
import { check, sleep } from 'k6'; export function exportfn1 { sleep(1); }
File: main.js
import { check, sleep } from 'k6'; import { exportfn1 } from '/opt/lib/helper-functions.js'; import http from 'k6/http';
Config file:
{ "scenarios": { "scenario1": { "executor": "constant-vus", "vus": 5, "duration": "10s", "gracefulStop": "0s", "exec": "exportfn1" } } }
Docker command used to run K6:
docker run --rm -v "$(pwd)"/config.json:/etc/config/config.json:z -v "$(pwd)"/helper-functions.js:/opt/lib/helper-functions.js:z -i repo/k6:0.31.0 --config /etc/config/config.json run - < main.js
Error message:
level=error msg=“There were problems with the specified script configuration:\n\t- executor scenario1: function ‘exportfn1’ not found in exports”
I seem to, on the outset, following documentation here - but unable to figure out why the function is inaccessible.
Thanks in advance for any insight.