This section lists a few of the most common k6 code examples and popular tutorials.
Example of one HTTP GET request.
HTTP Authentication and authorization
Scripting examples on how to use different authentication or authorization methods in your load test.
Correlating Tokens and Dynamic Data
Scripting examples to correlate dynamic data in your test script.
Scripting examples on how to parameterize data in a test script.
Scripting examples parsing HTML content.
Filling and Submitting HTML Forms
Scripting example on how to handle HTML forms in a load test.
Scripting examples on how you can interact with cookies during your load test, if required.
Scripting examples on how to execute a load test that will upload a file to the System Under Test(SUT).
Advanced API example
This example covers the usage of different k6 APIs for API load testing.
Scripting example on how to generate UUIDs in your load test.
Information on how to load test HTTP/2.
Scripting example on how to test websocket APIs.
Load Testing SOAP API.
Transport Layer Security (TLS)
TLS is the mechanism through which encrypted connections can be established between clients and servers on the web and through which data can flow with integrity intact.
Generating realistic data using faker.js
Reference project demonstrating how to generate data with realistic traits at runtime using faker.js.
Crawl a web page
Stack overflow answer demonstrating how to crawl a web page.
Bundling and transpilation
Reference project demonstrating how to use webpack and babel to bundle node modules or transpile code to ES5.1+ for usage in k6 tests.
Use checks and thresholds for unit testing.
How to use Datadog alerts and Thresholds to fail your load test
This article will show how to use Datadog alerts and Thresholds to fail your load test.
Load Testing Your API with Postman
How to use postman collections in k6?
Load testing with Swagger/OpenAPI
How to generate a load test script out of an OpenAPI document.
Performance monitoring with cron and k6
This tutorial will show you how to schedule k6 tests with cron to monitor the performance of your system.
Integrating k6 with Apache Kafka
How to send k6 output to Apache Kafka?
Load testing GraphQL with k6
The popularity and adoption of GraphQL have been impressive in the last years, this post provides an example using k6 to load testing a GraphQL service.
Load Testing RESTful APIs with k6
Let's take a look at how we can use the k6 open source load testing tool to performance test REST API endpoints.
How to control a live k6 test, with these built-in commands
This article takes a look at the k6 pause/resume/scale/stats/status commands, and how to use them to control and query a remote k6 instance running a test.