How to write a postman test to compare the response json against another json?

后端 未结 6 1411
闹比i
闹比i 2021-01-06 12:41

I have the below json response after running a postMan test of a Rest API:

    {
    \"glossary\": {
        \"title\": \"example glossary\",
        \"Gloss         


        
6条回答
  •  不思量自难忘°
    2021-01-06 13:21

    You can write javascript code inside Tests tab of Postman. Just write simple code to compare and check result in Tests.

    var serverData = JSON.parse(responseBody);
    var JSONtoCompare = {}; //set your predefined JSON here.
    tests["Body is correct"] = serverData === JSONtoCompare;
    

提交回复
热议问题