pm.expect(pm.response.json().email).to.eql(pm.variables.get("email_address"))
the email address in the env variable will be added either with caps or no caps, is there a way I can force the pm.expect to ignore upper or lower case?
pm.expect(pm.response.json().email).to.eql(pm.variables.get("email_address"))
the email address in the env variable will be added either with caps or no caps, is there a way I can force the pm.expect to ignore upper or lower case?
Hi @thingmie
Try this;
let text = "HeLlO WoRlD!";
console.log(text);
let result = text.toLowerCase();
console.log(result);
Output;
Many thanks @w4dd325, although I get an error
response.emailAddress is my example… you would need to change this to the nested structure of your JSON…
Looking at your original post your JSON would be;
response.email
But I wouldn’t be able to confirm this unless your shared your response body.
but if the email_address env var = [email protected] it fails.
It would fail as you have only instructed the code to change the response value to lower case, not your environment variable.
if you want both to be set as lower case you would have to change your assertion to;
pm.expect(email).to.eql(pm.environment.get("email_address").toLowerCase());
You are an absolute star @w4dd325 that’s worked out perfectly. top-man, have a great day.
Lastly, Is this structure ok? @w4dd325 I need to verify 3 properties in 1 test.
Looks ok to me.
Does it pass?
yeah, but I’m not sure how to mock the _id and email_verified values to prove it.
What do you mean by “mock the _id and email_verified values”?
These are in your response, right?
If you want to see the values of those properties then just console log it.
I wondered if i could change the values during runtime so i can test the logic; and yes they’re in the response.