K6 how run node command in the setup function

967 views Asked by At

Please excuse my limited K6/Javascript knowledge.

I have been given a javascript file that can be used to create a batch of users to be used within my k6 load test.

The script is currently ran from the commmand line using this command:

node helpers/createUsers.js 10

I want to run this script in the 'setup' function in K6.

Can I run node commands directly in K6 as above, or do I have to turn it into an export function and then call it?

1

There are 1 answers

0
Jeeva On

To my knowledge, you cannot run nodeJS or any nodeJS modules directly from a k6 test script. If the script helpers/createUsers.js is using any node modules, then you should follow this. and have the script in the setup() function.