Load Testing · Junior · Question 57 of 75
How do you read an environment variable in a k6 script?
- 1
import.meta.env.BASE_URL - 2
__ENV.BASE_URL - 3
process.env.BASE_URL
Show the answer
Correct answer: __ENV.BASE_URL
Explanation
k6 doesn't run on Node.js, so there is no process. Variables come from the system or -e BASE_URL=... and are read via __ENV.