How can we assert the boolean data type in postman tests

Viewed 3569

I want to assert the boolean data type in the postman. The data value could have true or false. How should we achieve this? I m using this code to verify but it will pass only if it's true but I want to validate if the value is false as well.

pm.test("Verify the past event dvr details", function () {
    var jsonData = pm.response.json();
 pm.expect(jsonData.data.entries[0].live_stream_rule.target_stream.dvr.is_available).to.be.true;
});
2 Answers

[PLEASE NOTE: This answer is incorrect and contains invalid code- see answer by Stanislav Scurtu]

If this what you're thinking of?

const isAvailable = jsonData.data.entries[0].live_stream_rule.target_stream.dvr.is_available
pm.expect(typeof isAvailable).to.be('boolean')
pm.test("Verify the past event dvr details", function () {
    var jsonData = pm.response.json();
 pm.expect(jsonData.data.entries[0].live_stream_rule.target_stream.dvr.is_available).to.be.a("boolean");
});
Related