Load Testing · Middle · Question 15 of 76
Where in a k6 script can you call open() to read a file?
- 1Only inside the default function, once per iteration
- 2Only in the init context, outside the default function
- 3Only inside
setup(), before the VUs start
Show the answer
Correct answer: Only in the init context, outside the default function
Explanation
File reads happen during init, when k6 prepares each VU. Calling open() in VU code throws an error.