2

I am looking for a way to assert the entire response of my API:

Error screenshot

The following error has occurred:

Asserting screenshot

n-verbitsky
  • 552
  • 2
  • 9
  • 20
Dominic
  • 31
  • 1
  • 9

1 Answers1

0

If you make a separate request, to first save the response data to a variable:

let myData = xml2Json(responseBody)
pm.globals.set('myData', JSON.stringify(myData))

You could then try this, in the second request, to check the whole response body against the save variable:

let myResponseData = xml2Json(responseBody)

pm.test('Body is Correct', () => {
    pm.expect(myResponseData).to.deep.eql(JSON.parse(pm.globals.get('myData')))
})
Danny Dainton
  • 23,069
  • 6
  • 67
  • 80
  • This will compare the data with the same set of data, so this test will always pass. Look at [this answer](https://stackoverflow.com/a/52105737) that follows the same approach, but saves the data the first time, and compares it with each follow up request. – AutomatedChaos Feb 20 '19 at 16:10
  • Ha, I just realised that after I posted it and then went into a meeting so I couldn't make the change. My bad. That reference is what I had in mind rather than checking the exact same thing :( – Danny Dainton Feb 20 '19 at 16:51