How to recal saved response in tests?

Hi,

Is it possible to access the collections saved Examples inside tests?

When writing my test scripts, I would like to access the example response body inside the test. Then I would want to compare the structure of the example response body with the actual response and see if the structures match.

Thanks in advance

Hi @tomas.suen,

Correct me if I am wrong, I am guessing you are talking about the Mocking functionality in Postman, if you are, the example response is getting returned back to you as is. There is no need to check if the structures match.
The only thing you have to do is ensure that the URL’s match between the sent request and the saved example request. The following link should be helpful to you: https://learning.getpostman.com/docs/postman/mock_servers/mocking_with_examples/

Regards,
Aamir

I have a very similar question. I have manually tested my API, and am sure that it currently works. So I have build a collection that exercises most of the functionality, and have saved a response for every request, and renamed the response ‘Success’.

Whenever I make a change to the API, I want to make sure that I haven’t broken anything. So I would like to run the collection, and every test wants to do:
Is the response from the API identical to the Saved Response called ‘Success’?

To do this, can I load the saved response named ‘Success’ into an object?