Load data file from command line

You can pass the filename as an environment variable like this k6 run --env MY_CONFIG_FILE=production.json, and then in your script you can have something like this:

const data = JSON.parse(open(__ENV.MY_CONFIG_FILE));
2 Likes