- There is a lot of information present in the Headers section but our testing should be testing the "Content-Type".
- Majorily, what does the "Content-Type" section represent Response Format => JSON, XML, HTML, etc. The format can be (let's say): application/json; which is termed as "mime type". The type of response/data is called mime-type.
- So, we need to verify if the content type is in JSON Format or not.
- We can also perform validation on the "Connection" field.
- We can also perform validation on the "Expires" field.
-
One issue of testing the cookies is that they are prone to change dynamically or their values keep on changing.
-
But there are some cookies whose value won't change each time dynamically. So we can validate those cookies.
-
Assertion =>
pm.expect(pm.cookies.has('language')).to.be.true;
-
Assertion =>
pm.expect(pm.cookies.get('language')).to.eql('en-gb');
- As the response time can also vary depending on multiple factors, we try to check if the Response time is under a specified time limit.
- Asserting if the data types of all fields in the JSON File are correct.
- Asserting the array properties: Checking if an Array is empty and if it contains particular items:
pm.expect(jsonData.courses).to.include("Java");
pm.expect(jsonData.courses).to.have.members(["Java","Selenium"]);
- The values that are present in the respective fields in Response in the JSON Data file can also be validated:
pm.expect(jsonData.id).to.eql(1);
Testing the Pre-Request Scripts along with the Test Scripts at the Collection, Folder, and Request Level as well:
When we use the Response obtained from an API obtained as a result of some Request sent by the user; as the Request for another/next API; then that is termed as Chaining.
Here; the Response obtained from API1 is sent as a Request for API2