Writing Basic k6 Scripts
Create your first k6 script to send HTTP requests and simulate virtual users.
Start Your k6 Script Journey
Welcome to writing k6 scripts! k6 uses JavaScript to define your load tests, making it familiar for many developers.
A k6 script describes what your virtual users will do and how the load should be simulated.
- Define user actions like visiting pages or logging in.
- Specify the number of virtual users (VUs) and test duration.
- Validate server responses to ensure correctness.
Anatomy of a k6 Script
Every k6 script typically has two main parts:
- The
optionsobject: Here you configure test-wide settings like virtual users (VUs) and test duration. - The
defaultfunction: This is where your virtual users' actions are defined. It's executed repeatedly by each VU.
Think of the default function as the "main loop" for each virtual user.
All lessons in this course
- k6 Installation and CLI
- Writing Basic k6 Scripts
- Checks, Thresholds, and Metrics
- Groups and Tags for Organizing Tests