The k6 module contains k6-specific functionality for writing load tests. This is the core module that provides essential functions like checks, groups, and sleep.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/grafana/k6-docs/llms.txt
Use this file to discover all available pages before exploring further.
Import
Functions
check()
Runs one or more checks on a value and generates a pass/fail result but does not throw errors or interrupt execution upon failure.Value to test.
Tests (checks) to run on the value. Each key is a description, and each value is a function that returns a boolean.
Extra tags to attach to metrics emitted.
Returns
true if all checks have succeeded, false otherwise.Checks are not asserts. A failed assertion throws an error, while a check always returns with a pass or failure. Use thresholds to control failure conditions.
fail()
Immediately throws an error, aborting the current VU script iteration.Error message that gets printed to stderr.
fail() does not abort the test or exit with non-0 status. It only aborts the current iteration. To halt test execution, use test.abort() from k6/execution.group()
Runs code inside a group. Groups organize results in a test and tag metrics accordingly.Name of the group.
Group body - code to be executed in the group context.
The return value of the function.
sleep()
Suspends VU execution for the specified duration.Duration, in seconds.
randomSeed()
Sets seed to get a reproducible pseudo-random number usingMath.random.
The seed value.
Using the same seed value across iterations produces the same sequence of random numbers.