I have a request where the body of the response contains only a boolean.
How do i create an assertion that it is false?
I tried pm.test(āResponse should be falseā,function(){
pm.response.to.eql(āfalseā)
})
Im getting the error AssertionError: expected { Object (id, _details, ā¦) } to deeply equal āfalseā
praveendvd
(Praveen)
2
Hi false is a bool , so needs to be compared with one too . You can use any of the below codes
pm.response.to.eql(false)
or
pm.expect(true).to.be.false
1 Like
vdespa
(vdespa)
3
Hi @hannahbroch
It really makes a difference if your response is JSON or simply text.
If you are getting something like:
{
"created": false
}
you should parse it with pm.response.json()
first.
If this is not JSON, try something like:
pm.test("Should contain false", () => {
pm.expect(pm.response.text()).eql('false');
pm.expect(pm.response.text()).to.contain('false');
});
thanks! this worked great