I am doing automation script for Functional testing my query is
- Send the request and store the entire response body in one file.
- Again they send the request and get the new response.
- Compare the new response body with a stored response file.
- Previous response and new response should be equal
I have tried below solution
var serverData = json.parse (responseBody);
var JSONtoCompare ={};
tests ["Body is correct"] = serverData === JSONtoCompare;
I am getting an error below:
Body is correct | AssertionError: expected false to be truthy.
so please help me to overcome this issue. I want to store the entire response in one file and compare it with a new response in the postman.


In the Postman, using variable to compare JSON object more easy and fast instead of file save.
Also only manual saving possible by selecting
Save Responsein output Body sectionTwo APIs call possible for your test scenario.
First API Call will save into
first_responsevariableSecond API Call will compare between
first_responsevariable andit's response.*Both API is save REST endpoint with save parameter
1. First API call, save it in
Teststab2. Second API call, compare it in
TeststabThe
_.isEqual()function: is used to find that whether the 2 given arrays(or object) are same or not.So you can compare two JSON postman responses using this method.
3. Auto testing.
Also you can test automatically by
Run CollectionornewmanSelect
Run CollectionStart
Run CollectionRun Result
Newman test result
#1 Export collection
#2 run it by
newman- it should be install bynpm install -g newman