How to test if an image was returned in the response?

App information

  • App Type [Native App]
  • Postman Version [7.3.4]
  • OS: [macOS Mojave 10.14]

If you run a get request, no special edits needed, on https://cdm17217.contentdm.oclc.org/digital/iiif/p17217coll1/3/full/full/0/default.jpg you’ll receive an image through the IIIF (international image interoperability framework) image API endpoint… I’m working on replacing how this image is served and want to check response times with the replacement compared to how it works now.

I would like to run a GET request test inside one of my collections but I’m not sure what the code would be in the “Tests” tab. Executing the GET with the above link (old implementation), Postman shows the image, but says “This request does not have a body.” When I enter in the new request URL (new implementation), I’d just like to test I still receive an image in the body and then compare the speeds.

I’m assuming I could test Content-Type = image/jpeg; but again, this is my first day with Postman and I’m a noob. I’d like to use this as a substitute for setting up an entire JMeter test

Edit
I’m using this to test that content-type is there, but not sure how to check its value.

pm.test("Content-Type header is present", function () {
    pm.response.to.have.header("Content-Type");
});

SOLVED

pm.response.to.be.header("pm.response.to.be.header("Content-Type", "image/jpeg; charset=UTF-8")
2 Likes