Skip to content

Instantly share code, notes, and snippets.

@JamesMessinger
Created July 27, 2017 19:22
Show Gist options
  • Save JamesMessinger/ad0746045e29497e1b1e22f8fa9ae39b to your computer and use it in GitHub Desktop.
Save JamesMessinger/ad0746045e29497e1b1e22f8fa9ae39b to your computer and use it in GitHub Desktop.
Postman BDD example
describe('Get customer info', () => {
it('should return a valid response', () => {
response.should.have.status(200);
response.should.be.json;
response.body.should.not.be.empty;
});
it('should set the Location header', () => {
response.should.have.header('Location');
});
it('should match the customer schema', () => {
var customerSchema = JSON.parse(environment.customerSchema));
response.body.should.have.schema(customerSchema);
});
it('should return the correct customer', () => {
response.body.id.should.equal(12345);
response.body.age.should.be.above(18).and.below(99);
response.body.firstName.should.be.a('string').and.not.empty;
response.body.lastName.should.be.oneOf(['Smith', 'Jones', 'Robinson']);
});
});
@Maheshin
Copy link

Maheshin commented Jan 2, 2018

Hey,

when I running this in Postman getting an error saying Describe is not defined ? I am on Version 5.5.0 (5.5.0) please help

Copy link

ghost commented Sep 14, 2018

You should install Postman-BDD first. But now Postman has its own BDD syntax.

@lflucasferreira
Copy link

lflucasferreira commented Feb 14, 2021

You should install Postman-BDD first. But now Postman has its own BDD syntax.

Excuse me, but how to use the Postman's BDD own syntax? Is there something different? Where can I find the documentation of it? TIA.

@JamesMessinger
Copy link
Author

See the Postman documentation for examples of their new test syntax:
https://learning.postman.com/docs/writing-scripts/script-references/test-examples/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment