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;
});
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;
});
Share
Improve this question
edited Nov 21, 2020 at 11:14
Sarun UK
6,7667 gold badges26 silver badges50 bronze badges
asked Nov 21, 2020 at 10:34
Prabu GauthamPrabu Gautham
611 silver badge2 bronze badges
1
- You would need to add chaijs./plugins/chai-asserttype to be able to check if it's a boolean. What other values could it be? Are you trying to make sure that it exists? – Arlemi Commented Nov 23, 2020 at 15:01
2 Answers
Reset to default 3pm.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");
});
[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')