Asserting the response is false

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ā€™

Hi :eyes: false is a bool , so needs to be compared with one too . You can use any of the below codes :grin:


pm.response.to.eql(false)

or 

pm.expect(true).to.be.false
1 Like

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