Compare 2 strings

I am comparing 2 strings. The first string, I get it from the excel sheet and the 2nd string I get it from the response.

Example: 1st String: “abc”
2nd String from response: “abc xyz”

When I compare these 2 I should get an error as “abc” is not equal to “abc xyz”.
But I see that I am not getting the error instead the test is getting passed.

Below is the test function:

const jsonData = pm.response.json();

var resName = jsonData.hits[0].Name;

var inputName = pm.iterationData.get(“name”);

pm.test(‘Name’, function(){

Here the resName is ‘abc xyz’ and inputName is ‘abc’. This should throw an error but the test is getting passed

Postman uses CHAI for assertions.

Causes all .equal , .include , .members , .keys , and .property assertions that follow in the chain to use deep equality instead of strict (=== ) equality.

Just removed the deep from the assertion.


I tried to.eql as well. No change. Still the test passes which is invalid

It should be the following.

pm.test("Name", function(){


Because you aren’t calling the toUpperCase() function properly, the way you had it is basically comparing the text [Function: toUpperCase] for both variables. (Therefore passing each time).

1 Like

@mdjones Thanks a lot. You made my day. Have a great year ahead