Skip to content

Instantly share code, notes, and snippets.

@safaorhan
Created March 22, 2018 13:05
Show Gist options
  • Save safaorhan/23998f580c3dd4ac278a81d297c82e80 to your computer and use it in GitHub Desktop.
Save safaorhan/23998f580c3dd4ac278a81d297c82e80 to your computer and use it in GitHub Desktop.
GET /customer
//status code is 200
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
//reponse body is json()
pm.test("Response body should be json",function(){
pm.response.to.have.jsonBody();
})
var body = pm.response.json();
var id = pm.environment.get("CUSTOMER_ID");
var email = pm.environment.get("CUSTOMER_EMAIL");
var firstName = pm.environment.get("CUSTOMER_FIRST_NAME");
var lastName = pm.environment.get("CUSTOMER_LAST_NAME");
var schema = {
type: "object",
properties: {
id: {
type: "integer",
minimum: id,
maximum: id
},
createdDate: {
type: "string"
},
firstName: {
type: "string",
pattern: firstName
},
lastname: {
type: "string",
pattern: lastName
},
email: {
type: "string",
pattern: email
}
}
};
pm.test("Schema and values are valid ",function(){
pm.expect(tv4.validate(body, schema)).to.be.true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment