parsy2
(Parsy)
1
When I make a request, I’m expecting an error with code 79 , but I cant get to validate it:
My response body is:
{
“errors”: [
79
]
}
I am trying with:
var jsonData = JSON.parse(responseBody);
pm.test("Proper error ", function () {
pm.expect(jsonData.errors).to.eql(79);
});
But I get:
Proper error | AssertionError: expected [ 79 ] to deeply equal 79
Hey @parsy2
errors
is an array so it wouldn’t equal that value.
You could try this:
.to.include(79);
More information about the chai library can be found here:
https://www.chaijs.com/api/bdd/
parsy2
(Parsy)
3
This way:
var jsonData = JSON.parse(responseBody);
pm.test("Proper error ", function () {
pm.expect(jsonData.errors).to.include(79);
});
Returns this:
Proper error | AssertionError: expected [] to include 79
Was the response body the same? Did that return an empty errors array?
I can’t see what you can so I’m only offering a possible solution.