K6 Best Practices

Hi Team,

I’m working with K6 and want to know if there are any specific best practices or JavaScript standards that help us better maintain the project.

Hi @Gerard,

I have a few of them in base of my experience:

  • Code Resilient: Running large tests
  • Use shared array to get data: SharedArray
  • Don’t put much logic in Init section (it consume too much CPU so in cloud executions it could fail)
  • Use Options in a separate file.
  • Use scenarios for separate your results.
  • Use tags in your GET request (if dont your reports will have a large number of results jejeje)

Hope it helps
Greetings.
Gino

6 Likes

Thanks @Gino

Any suggestions on the JavaScript side?

You can take a look at these k6 templates for examples of highly modularized scripts using different libraries.

A set up like this could help you mix and match test logic, set logic dynamically through environment variables, et cetera.

4 Likes