Response Validations
Response Validations
(Adding Tests)
▪ Status code
▪ Headers
▪ Cookies
▪ Response time
▪ Response body
Chai Assertion Library
If you want to test for the status code being one of a set, include them all in an
array and use one of
{
"id": 1,
"name": "John",
"location": "india",
"phone": "1234567890",
"courses": [
"Java",
"Selenium"
]
}
{
"id": 1,
"name": "John",
"location": "india",
"phone": "1234567890",
"courses": [
"Java",
"Selenium"
]
}
});
Validating JSON Schema
Response
{
"id": 1,
"name": "John",
"location": "india",
"phone": "1234567890",
"courses": [
"Java",
"Selenium"
]
}
JSON schema
var schema={
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"location": {
"type": "string"
},
"phone": {
"type": "string"
},
"courses": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"required": [
"id",
"name",
"location",
"phone",
"courses"
]
}