Hello,
I am testing an API that produces a body response with new lines, precisely, I am testing an example that returns this block (also with empty lines at the top and bottom)
SciTegic07202312172D
0 0 0 0 0 0 999 V3000
M V30 BEGIN CTAB
M V30 COUNTS 6 6 0 0 0
M V30 BEGIN ATOM
M V30 1 C 0 2 0 0
M V30 2 C -0.866 1.5 0 0
M V30 3 C -0.866 0.5 0 0
M V30 4 C 0 0 0 0
M V30 5 C 0.866 0.5 0 0
M V30 6 C 0.866 1.5 0 0
M V30 END ATOM
M V30 BEGIN BOND
M V30 1 2 1 2
M V30 2 1 2 3
M V30 3 2 3 4
M V30 4 1 4 5
M V30 5 2 5 6
M V30 6 1 6 1
M V30 END BOND
M V30 END CTAB
M END
I have tried using the assertion function as follows - by escaping the new lines with \n:
pm.test(“Response Test”, function() {
pm.response.to.have.body(“\nSciTegic07202312172D\n\n0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\nM V30 COUNTS 6 6 0 0 0\nM V30 BEGIN ATOM\nM V30 1 C 0 2 0 0\nM V30 2 C -0.866 1.5 0 0\nM V30 3 C -0.866 0.5 0 0\nM V30 4 C 0 0 0 0\nM V30 5 C 0.866 0.5 0 0\nM V30 6 C 0.866 1.5 0 0\nM V30 END ATOM\nM V30 BEGIN BOND\nM V30 1 2 1 2\nM V30 2 1 2 3\nM V30 3 2 3 4\nM V30 4 1 4 5\nM V30 5 2 5 6\nM V30 6 1 6 1\nM V30 END BOND\nM V30 END CTAB\nM END\n”)
});
However, my test fails without explaining what differences there are between response and expected result:
Response Test | AssertionError: expected response body to equal ‘\nSciTegic07202312172D\n\n0 0 0 0 …’ but got ‘\n SciTegic07202312172D\n\n 0 0 0…’
It just raises an AssertionError. I am using Postman June 2023 (v10.15).
I checked already checked:
Thanks,