0Pricing
Load Testing & Performance Benchmarking (JMeter & k6) · Lesson

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 options object: Here you configure test-wide settings like virtual users (VUs) and test duration.
  • The default function: 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

  1. k6 Installation and CLI
  2. Writing Basic k6 Scripts
  3. Checks, Thresholds, and Metrics
  4. Groups and Tags for Organizing Tests
← Back to Load Testing & Performance Benchmarking (JMeter & k6)