AssertionError: expected ' ' to deeply equal

I’m validating one variable value in the response of Postman.
Here is my code:
var jsonArrayData = pm.response.json()


pm.test("Response body contains "+ jsonArrayData[0].fields.externalid, function(){



and here is the response:

Response body contains 283670438065 | AssertionError: expected ‘283670438065’ to deeply equal 283670438065

Also, find the screenshot for reference:

Hi @jagrutiwani0, this error is because you are comparing two different data types. Even the value is same here the data type is different.

So while storing the collection variable you can store using JSON.stringify() method,

else you can convert it to integer like this post.


Please try and let me know if this works :blush:


Hey, it’s working now. I converted both the variables to Integer. Thanks :slight_smile:

1 Like

Hi @bpricilla ,

What will I use for the comparison of string values?
Now I’m getting Response body contains Company Name asTestAPI49514 | AssertionError: expected ‘TestAPI49514’ to deeply equal undefined error.

@jagrutiwani0 You need to use JSON.stringify() method.

But in the above error it states that the variable is undefined.

1 Like

Hi @bpricilla ,

Thanks for noting it! The issue was with the variables. The same were stored in the environment as well as collection. So removed the one from the environment and keeping those variables in Collection. The assertion is working even without using JSON.stringify()

1 Like

Okay good to know that. All the best :bouquet: Let us know if you have any other issues.

1 Like