I am trying to determine why certain login tests are failing. To do so I need to examine the HTML that has been returned. While I realize that I can output this to the screen via console.log, it is cleaner and easier to read if it is output to a file. Is there anyway to write to the filesystem with k6?
Thanks
Unfortunately there's no way to write directly to the filesystem. That's mostly because of security and portability concerns when dealing with the distributed cluster and cloud execution.
For easier debugging, we recently added a --logformat=raw option that doesn't output debug information in the logs. If you run k6 run --logformat=raw script.js 2> debug.html, you'd get only the things you output via console.log() in the newly created debug.html
Thanks for the reply, I will look towards that for debugging. I guess I could also setup a collector server to record html/data as well.
Yes, it would probably be easier for debugging more complicated scenarios. Another possibility is passing things through JSON.stringify() before logging them and then parsing the resulting log with something like jq.
Closing this for now, since we don't currently plan to introduce support for writing files or other potentially unsafe operations. Logging with the --logformat=raw and --logformat=json options and the --httpdebug flag should cover most debug needs, though we can potentially reopen this issue if there's enough user demand and we decide to add some unsafe local debug execution mode in the future.
Most helpful comment
Unfortunately there's no way to write directly to the filesystem. That's mostly because of security and portability concerns when dealing with the distributed cluster and cloud execution.
For easier debugging, we recently added a
--logformat=rawoption that doesn't output debug information in the logs. If you runk6 run --logformat=raw script.js 2> debug.html, you'd get only the things you output viaconsole.log()in the newly createddebug.html