- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Different types of Asserts in Postman
There are different types of Asserts in Postman. We can add Assertions on different sections of the Response received. Some of the Assert types are listed below −
Assert on Response Code
pm.test["Status Code is 200"], function(){ pm.response.to.have.status(200) })
The above assertion passes if the Response code is 200.
pm.test["Status is OK"], function(){ pm.response.to.have.property('status', ' OK') })
The above assertion is applied on the Response property – status with value as OK.
Assert on Response time
pm.test("Response time below 600 milliseconds", function () { pm.expect(pm.response.responseTime).to.be.below(600) })
The above assertion passes if the Response time is below 600ms.
Assert on Response Format
pm.test("Response is of JSON type ", function(){ pm.response.to.be.json; })
The above assertion passes if the Response is of JSON type.
Assert on Response Header
pm.test("Header Of Response", function () { pm.response.to.have.header("Content-Encoding") })
The above assertion passes if the Response has a Content-Encoding Header.
Assert on Response Text
pm.test("Response", function () { pm.expect(pm.response.text()).to.include("Postman") })
The above assertion passes if the Response includes the text Postman.
Advertisements