k6 "some thresholds have failed" on API checks in CI
k6 exits non-zero when a configured threshold is crossed. For API testing this is usually a checks rate below 100% or http_req_failed above your limit, meaning some requests returned unexpected statuses or bodies.
What this error means
k6 ends with "some thresholds have failed" and marks a metric line (checks or http_req_failed) with a cross, failing the CI step even though the load ran.
checks.........................: 66.66% checks 2 out of 3
http_req_failed................: 33.33% 1 out of 3
ERRO[0003] some thresholds have failed
Common causes
API checks failed for some requests
A check on status or body did not pass for part of the traffic, dropping the checks rate below the threshold you set.
The service errored or was not ready under load
The API returned 5xx or refused connections during the run, raising http_req_failed above the allowed rate.
How to fix it
Inspect which check failed
- Read the per-check output to see which status or body assertion failed.
- Reproduce that request against the CI service.
- Fix the service or adjust the check to match correct behavior.
check(res, { 'status is 200': (r) => r.status === 200 });Ensure readiness before the test
Wait for a health endpoint so k6 does not send load before the API can serve it.
until curl -sf http://localhost:8080/health; do sleep 2; done
k6 run script.jsHow to prevent it
- Set thresholds that reflect a real pass bar (checks rate, error rate).
- Wait for service readiness before sending load.
- Keep checks specific to the status and body you expect.