k6 community forum

How to combine multiple ENV into one

In general, if we need to pass multiple environments into CLI, we need to use the command below

k6 run accept-case.js --quiet –env TT=1 --env PT=1 --env TESTTYPE=1 xxx.js

Is there any option to combine multiple environments var into one?

I don’t know what exactly combining will look like …

I guess you want that -e TT=1 -e TT=2 will produce __ENV.TT == [1, 2] ? This is not currently supported, you can open an issue.

Why do you particularly want to combine them instead of using separate ones?

Do you just need an array because you can run something like --env TT="[1,2,3,4,5]" and then have the following code:


which will produce:

INFO[0000] {"TT":"[1,2,3,4,5]"}
INFO[0000] "[1,2,3,4,5]"
INFO[0000] 4