InstallationMac:
Linux:
Windows: Download the installer from the K6 website UsageTo create a K6 test script, create a new file with the .js extension. In the file, add the following code:
This script will make a GET request to the example.com website. To run the test script, use the following command:
This will start the K6 test runner and execute the test script. |
OptionsYou can customize the behavior of the K6 test runner using the following options: : The number of virtual users to simulate : The number of times to repeat the test script : The duration of the test in secondsExamples To run a test with 10 virtual users for 60 seconds, use the following command:
To run a test with 100 virtual users for 120 seconds, use the following command:
ReportingK6 comes with built-in metrics about the test load and the system response. Key metrics include: , the end-to-end time of all requests (that is, the total latency) , the total number of failed requests , the total number of iterations |
Adding-checks-to-your-scriptNote that you need to import the check from the k6 library:
And you need to put the actual check in the default function:
Setting-test-criteria-with-thresholdTypes of thresholds: 1. Error rate
2. Response time
3. Checks
|
Cheatography
https://cheatography.com
K6 Cheat Sheet (DRAFT) by Monish Correia
The K6 cheatsheet is a comprehensive quick reference guide for users of the K6 load testing tool. It covers installation, usage, options, examples, assertions, reporting, and offers valuable tips and tricks. Whether you're a beginner or an experienced K6 user, this cheatsheet provides essential information for effective load testing.
This is a draft cheat sheet. It is a work in progress and is not finished yet.