Is there a convenient way to write the response body to an html file for debugging purposes?
Many Thanks
OTG Load Testing
Is there a convenient way to write the response body to an html file for debugging purposes?
Many Thanks
OTG Load Testing
The easiest thing was to console log the response body and redirect stderr to a file:
k6 run test.js 2>resp.html
Do a little editing and open in a browser
To somewhat improve the UX of that, you can also use the --logformat raw or --logformat json and --console-output=./path/to/console-log-file.log
Hi @ned does --console-output=./filename.log takes only the outputs from console.log() ?
I run the below command using the docker-compose setup.
docker-compose run k6 run --logformat raw tests.js --console-output=./test.csv
This shows me permission denied. Any thoughts ?
Note that --console-output with a windows version of k6 works perfectly fine.
Hope Ned doesn’t mind me jumping in ![]()
Yes, and also console.error(), console.info(), etc.
As for the permission denied error, that has to do with Docker. A few months ago the image was changed to use an unprivileged user, so if you want to write inside the container or to a bind volume (the default docker-compose.yml mounts ./samples:/scripts), you’ll have to specify the --user/-u option, either by making it run as root with -u root (not recommended), or by using the host’s UID/GID like so:
docker-compose run -u "$(id -u):$(id -g)" k6 run --logformat raw --console-output=/scripts/test.csv /scripts/stages.js
I’ll make a note to mention this in our docs.