admin管理员组文章数量:1397048
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')
本文标签: javascriptHow can we assert the boolean data type in postman testsStack Overflow
版权声明:本文标题:javascript - How can we assert the boolean data type in postman tests - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744149475a2592994.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论