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.Name;
var inputName = pm.iterationData.get(“name”);
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.
.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.
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).
@mdjones Thanks a lot. You made my day. Have a great year ahead