Test to see if value exists

I couldn’t get that to work @cmnazario
But thank you for the help.

I did find a solution, so I’m going to post it, to hopefully help someone else in the future.
Rather than searching through objects and arrays and confusing myself what-is-what.

I put this in the Tests tab.

string = JSON.stringify(pm.response.json());
if(pm.expect(string).to.include(‘2c9180897a5eb28b017a’)){
pm.test(“success”)
}
else{
pm.test(“fail”)
}

It will output in the console “success” if it finds the string
It outputs a big red error in the fail scenario
“error in evaluating the test script: AssertionError: expected”

But honestly… I spent enough time on this for now… so this works fine for what I was trying to achieve.

2 Likes