No results for

Powered byAlgolia
⚠️ This is archived documentation for v0.31. Go to the latest version

check( val, sets, [tags] )

suggest edits

Run checks on a value. A check is a test condition that can give a truthy or falsy result. The sets parameter contains one or more checks, and the check() function will return false if any of them fail.

Note that checks are not asserts in their traditional sense - a failed assertion will throw an error, while a check will always return with a pass or a failure. Failure conditions can then instead be controlled by thresholds, for more power and flexibility.

valanyValue to test.
setsobjectTests (checks) to run on the value.
tags (optional)objectExtra tags to attach to metrics emitted.


booleantrue if all checks have succeeded, false otherwise.


Using check() to verify that an HTTP response code was 200 and that body was 1234 bytes:

import http from 'k6/http';
import { check } from 'k6';
export default function () {
let res = http.get('');
check(res, {
'response code was 200': (res) => res.status == 200,
'body size was 1234 bytes': (res) => res.body.length == 1234,