Tests not registering with Postman?

I have a test set up to run after my API call. The purpose of the test is to find a field and save it as a variable. I don’t know what exactly is happening, but no matter how I code this test, Postman says there are no tests for the request. I genuinely have no idea what I could have written incorrectly to make the test invisible when running this request. Has anyone run into something similar and fixed it? I’ve seen other topics similar to this but their solutions haven’t worked for me so far.

Hey @brcox9090,

Welcome back to the forum :trophy:

There isn’t actually anything getting tested or asserted on within that script. It’s parsing the response body and looping through the data until it meets the condition before creating a variable. Nothing is tested in that flow.

This is a very basic example of a test:

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

You use the pm.test function and inside the function it makes an assertion. In this case, it’s using a built in helper pm.response.to.have.status(200); but this could also be pm.expect(pm.response.code).to.equal(200)

We have lots of pages on the learning center about how to write tests in Postman: