Optionally treat failed checks as errors in CSV

Hello,
I am trying to find a way to have failed checks reflected as errors in the CSV file (i.e. in the fields error and error_code).
Can it be somehow configured, maybe involving expected_response metric?
Thank you in advance.

More details below:
For example, my request is expected to return some error response (400) and with checks mechanism I compare actual response code to 400.
The problem for me is to detect failed responses from CSV file when I get anything else instead of 400.
In the K6 output and summary json I see the failed checks statistics, but I would like to be able to treat failed checks as errors in the CSV file.

metric_name,timestamp,metric_value,check,error,error_code,expected_response,group,method,name,proto,scenario,service,status,subproto,tls_version,url,extra_tags
http_reqs,1623681406,1.000000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_duration,1623681406,5.507000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_blocked,1623681406,0.630000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_connecting,1623681406,0.143000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_tls_handshaking,1623681406,0.000000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_sending,1623681406,0.518000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_waiting,1623681406,4.885000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_receiving,1623681406,0.104000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_req_failed,1623681406,1.000000,,,1501,false,,POST,http://localhost:8000/abc,HTTP/1.0,options_scenario,,501,,,http://localhost:8000/abc,
http_reqs,1623681406,1.000000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_duration,1623681406,6.904000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_blocked,1623681406,0.628000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_connecting,1623681406,0.142000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_tls_handshaking,1623681406,0.000000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_sending,1623681406,0.519000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_waiting,1623681406,6.351000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_receiving,1623681406,0.034000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
http_req_failed,1623681406,0.000000,,,,true,,HEAD,http://localhost:8000,HTTP/1.0,options_scenario,,200,,,http://localhost:8000,
checks,1623681406,1.000000,Expected response code for Request 1 is 200,,,,,,,,options_scenario,,,,,,
checks,1623681406,0.000000,Expected response code for Request 2 is 400,,,,,,,,options_scenario,,,,,,
data_sent,1623681406,334.000000,,,,,,,,,options_scenario,,,,,,
data_received,1623681406,849.000000,,,,,,,,,options_scenario,,,,,,
iteration_duration,1623681406,9.581895,,,,,,,,,options_scenario,,,,,,
iterations,1623681406,1.000000,,,,,,,,,options_scenario,,,,,,

Hi @nsavelyeva,
The idea behind expected_response is exactly what you are looking for and by default, only responses between 200 and 399 are marked with expected_response: true (as most people, in general, don’t expect 400+ error codes in load tests) so this should already work you as you’ve shown in the CSV file.
You can of course configure the expected status codes as shown in this example

but I would like to be able to treat failed checks as errors in the CSV file.

I don’t understand what you want here. The CSV file is just that a CSV file with the metrics values (and tags) and in this case you have 2 checks one with a value of 1 one with a value of 0 which means that the second one has failed.