How can we see which requests had failed tests?

Hi, we have some tests per requests but are unable to see which requests had these failed tests.


--http-debug didn’t help. Any tip how we can see specifically which requests had failed tests?


check() returns true if all of the conditions passed, or false if any one failed, so you can use that to console.log() (or emit in a custom metric) the responses which failed to pass the checks. Like this:

import http from "k6/http";
import { sleep, check } from "k6";
import { Counter } from 'k6/metrics';

let errors_metrics = new Counter("my_errors");

export default function () {
    let resp = http.get("");

    let passed = check(resp, {
        "http2 is used": (r) => r.proto === "HTTP/2.0",
        "status is 200": (r) => r.status === 200,
        "content is present": (r) => r.body.indexOf("whatever") !== -1,

    if (!passed) {
        console.log(`Request to ${resp.request.url} with status ${resp.status} failed the checks!`);
        errors_metrics.add(1, { url: resp.request.url });

You can find all properties of the Response object here:

1 Like