lundi 13 mars 2017

How to match a JSON response value to Postman environment variable?

If an environment variable is set in Postnam, for example year, then I'd like to check if the JSON response for the filed birthYear matches the value of the variable.

I am trying with the following test:

var jsonData = JSON.parse(responseBody);
tests['Contents'] = environment.year === jsonData.birthYear; 

This test always failes. birthYear is 1910 and year is also 1910.

If I try the same test but for a field that has a string value then it works correctly - pass when the values match and fail when the don't.

How should I proceed in order to test the integer values as well as the string ones?

Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire