Skip to main content
The k6 module is the main module that provides core k6 functionality for load testing scripts.

Functions

check(val, sets, [tags])

Runs checks on a value and emits check metrics.
any
The value to test
object
Object with check names as keys and check functions as values
object
Optional tags to attach to the check metrics
boolean
Returns true if all checks passed, false otherwise

fail([message])

Throws an error and interrupts the VU execution.
string
Error message to display

group(name, fn)

Runs a function within a named group for better organization and metrics.
string
Name of the group
function
Function to execute within the group. Must be synchronous.
any
Returns the value returned by the function
The group() function does not support async functions. Use synchronous functions only.

randomSeed(seed)

Sets the seed for the random generator used for this VU.
integer
Seed value for the random number generator

sleep(seconds)

Suspends VU execution for the specified duration.
number
Duration in seconds (can be fractional)

Examples

Basic Load Test