k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Guides

Session recording / HAR support

How to use the HAR converter

k6 has a built-in HAR converter that will read HAR files and convert them to k6 scripts that can then be executed:

k6 convert myfile.har

The above command will make k6 read myfile.har, convert it into k6-compatible Javascript and then output it on stdout (you can use the -O option to save to a file, or just redirect the output on stdout to a file).

How to perform a session recording for k6

You can use the HAR converter to convert HAR files generated by e.g. Firefox or Chrome. This enables you to easily record user sessions for your site/app and then replay those sessions in a k6 load test.

Here are the basic steps you need to take to make a recording in Chrome (Firefox is similar):

  1. Open a new incognito window in Chrome (not really necessary, but using an incognito window means you won't be sending a lot of cookies etc that might have been saved by your browser)

  2. Open up Chrome developer tools (CMD-SHIFT-I on a Mac)

  3. Click the "Network" tab

  4. Click the "Preserve log" checkbox if you want to make a recording of several successive page loads

  5. Go to your site and start doing whatever you'd like your simulated load test users to be doing

  6. When done, right-click on the list of URLs in Chrome developer tools and choose "Save as HAR with content" - see screenshot below

  1. Convert the HAR file using k6: k6 convert -O myscript.js myfile.har

  2. Run the resulting myscript.js script: k6 run myscript.js

Recommended is of course to review the script before running it. There may be dynamic data used on your site - CSRF tokens or whatnot - that will be hardcoded into the k6 script and which you may want to replace with dynamic data that k6 gets from the server you are testing.