I am developing a API, and have a Postman collection used with extensive tests on the endpoints. I also used Examples to be able to mock a good chunk of the API.
However, whenever something is planned to change in the response, I have to edit the tests and examples in almost the same way. In some cases, it would make sense to have the test depend directly on the example response for a part, or even the entire response.
It would make it much easier for those tests to be able to reference the example value:
const expectedStatusCode = pm.examples[0].request.status; // ???
pm.test(`Status code is ${expectedStatusCode}`, () => {
pm.response.to.have.status(expectedStatusCode)
})
The Postman API reference how to access a lot of things, but there seems to be no way to either access the examples data nor read a file (so I could parse the collection JSON file, and fetch the value directy in the exported collection)