k6 community forum

Does pm.response.to.have.status(200) really not work?

Hi

I’m noticing that my k6 code coverted from Postman by postman-to-k6 behaves exactly like my Postman code.

Despite using pm.response.to.have.status(reason), which is unsupported in postman-to-k6

That’s a bit weird to me.

Typical test looks like (simplified):

postman[Request]({
name: “Get Journal selections (FHIR)”,
method: “GET”,
address:
“{{server}}/DIPS-WebAPI/HL7/FHIRDSTU2/ValueSet?_query=JournalGroupsProfile”,
headers: {
“Auth-ticket”: “{{AuthTicket}}”
},
post(response) {
pm.test(“Status code is 200”, function() {
pm.response.to.have.status(200);
});
},
});

Hi @tonivuc, not a postman-to-k6 developer (or user) but it says:

  • Textual response message: responseCode.name responseCode.detail pm.response.reason pm.response.to.have.status(reason) pm.response.to.not.have.status(reason)

Which IMO means that you can provide a string in postman and it will do some check with and it is this that is not supported not the integer code checking.

This code seems to be the one responsible and it confirms my suspicion :slight_smile:

I hope this clears it :smiley:

1 Like

Great answer, thanks!