I am using the following code to assert on a response field and this code was working just fine a couple of days ago and now it is failing.
pm.test(‘my variable’, function() {
var jsonData = pm.response.json();
pm.expect (jsonData.applicationData.myvariable).is.to.equal(pm.environment.get(‘myvariable’);
I then did a console.log on the pm.response.json and when the data was returned in the console I noticed there were a bunch of missing attributes. If I POST the call via Postman and manually view the response I can see all the attributes. So I was wondering if there is an issue with Postman and using the pm.repsonse.json to where it is maybe not properly parsing the response? If not, I’ll continue to look on our side to see what could have possibility changed.
Putting the test code and logging out the data from pm.response.json() to one side.
Do you see the expected data in the response view?
The test sounds like it’s doing exactly what it’s supposed to be doing and acting as a change detector - Something has changed the shape of the response data.
One thing that you could do moving forward, it to create some schema validation tests, that would allow you to see what’s changed against a known schema.
Without showing/displaying a visual comparison of what the response is and what you’re getting from the console log statement - it’s going to be tough to advise where to go here