Write data to file

I always was in situations when I need to save some data to file, like the response of the requests, different bodies etc. Is there an easy way to do this? will this be added in some future realeses? I want to avoid cli commands that outputs everything to file.
Something like fs.write would be nice to have.

Hi, welcome to the forum.

Because of the highly concurrent and potentially distributed nature of k6, it would be difficult to support writing to local disk like fs.write().

Instead you could use some type of distributed storage for this, like Redis or S3. There are a couple of Redis extensions for k6 that could help you with this, otherwise any system like S3 that exposes an HTTP API could be used. Though keep in mind that this will potentially impact performance of your test, and in the case of HTTP services would also skew your end-of-test summary results. You can avoid the metric skew by not depending on the summary and filtering these requests using tags in whatever output system you use.

You could also write a new k6 extension that stores files on the local filesystem, just be aware that this likely won’t be supported in k6 Cloud and would only work for your local single-instance tests.