Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
Created August 4, 2019 05:25
Show Gist options
  • Save danielplawgo/fc06ac4a3282ec34fb706a5819c44f32 to your computer and use it in GitHub Desktop.
Save danielplawgo/fc06ac4a3282ec34fb706a5819c44f32 to your computer and use it in GitHub Desktop.
Postman - asserty w automatycznych testach
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
pm.test("Return added product data", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.Success).to.eql(true);
pm.expect(jsonData.Value.Id).to.eql(1);
pm.expect(jsonData.Value.Name).to.eql("Name1");
});
pm.test("Return added product data", function () {
pm.response.to.have.body('{"Value":{"Id":1,"Name":"Name1"},"Success":true,"Errors":[]}');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment